Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2015
    Posts
    726
    Plugin Contributions
    1

    Default PHP Fatal error: Uncaught Error: [] operator not supported for strings

    I am worrking on creating a pixel for facebook. I got everything to work except on the checkout success page I get an error

    Below is the code causing the error. Can someone assist me or lead me in the right direction on getting this solved.


    PHP Fatal error: Uncaught Error: [] operator not supported for strings in xxx


    $product_ids[] = (int)$product['id'];

  2. #2
    Join Date
    Jan 2015
    Posts
    726
    Plugin Contributions
    1

    Default Re: PHP Fatal error: Uncaught Error: [] operator not supported for strings

    sorry here is the piece of code. The error is coming from $product_ids[] = (int)$product['id'];

    -------------------------------------------------------------------------------------------------------------------------------

    case FILENAME_CHECKOUT_SUCCESS:
    if ($zv_orders_id > 0) {
    if(!class_exists('order')) require_once DIR_WS_CLASSES . 'order.php';
    $order = new order($zv_orders_id);
    $products = $order->products;
    foreach ($products as $product) {
    $product_ids[] = (int)$product['id'];
    }
    echo "fbq('track', 'Purchase', {\n
    value: " . number_format($order->info['total'], 2, '.', '') . ",\n
    currency: '" . $_SESSION['currency'] . "',\n
    content_type: 'product',\n
    content_ids: ['" . implode("','", $product_ids) . "']\n
    });";
    }
    break;

  3. #3
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,746
    Plugin Contributions
    22

    Default Re: PHP Fatal error: Uncaught Error: [] operator not supported for strings

    Maybe:
    Code:
    case FILENAME_CHECKOUT_SUCCESS:
    if ($zv_orders_id > 0) {
    if(!class_exists('order')) require_once DIR_WS_CLASSES . 'order.php';
    $order = new order($zv_orders_id);
    $products = $order->products;
    fbp_pids = array();
    foreach ($products as $product) {
    $fbp_pids[] = (int)$product['id'];
    }
    echo "fbq('track', 'Purchase', {\n
    value: " . number_format($order->info['total'], 2, '.', '') . ",\n
    currency: '" . $_SESSION['currency'] . "',\n
    content_type: 'product',\n
    content_ids: ['" . implode("','", $fbp_pids) . "']\n
    });";
    }
    break;

  4. #4
    Join Date
    Jan 2015
    Posts
    726
    Plugin Contributions
    1

    Default Re: PHP Fatal error: Uncaught Error: [] operator not supported for strings

    I tried your suggestion but it did not seem to work. Any other ideas?

  5. #5
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: PHP Fatal error: Uncaught Error: [] operator not supported for strings

    Quote Originally Posted by chadlly2003 View Post
    I tried your suggestion but it did not seem to work. Any other ideas?
    Please elaborate on "did not seem to work". Did the error go away? Did the desired result get seen? What didn't work? What error(s) are now being generated with the modification that balihr suggested (which looks reasonable).

    Other than there is a dollar sign missing
    fbp_pids = array();
    Should be:
    $fbp_pids = array();
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,746
    Plugin Contributions
    22

    Default Re: PHP Fatal error: Uncaught Error: [] operator not supported for strings

    Quote Originally Posted by mc12345678 View Post
    Please elaborate on "did not seem to work". Did the error go away? Did the desired result get seen? What didn't work? What error(s) are now being generated with the modification that balihr suggested (which looks reasonable).

    Other than there is a dollar sign missing
    fbp_pids = array();
    Should be:
    $fbp_pids = array();


    Sorry for the typo... mc12345678 is right, there's a dollar sign missing. Try this:
    Code:
    case FILENAME_CHECKOUT_SUCCESS:
    if ($zv_orders_id > 0) {
    if(!class_exists('order')) require_once DIR_WS_CLASSES . 'order.php';
    $order = new order($zv_orders_id);
    $products = $order->products;
    $fbp_pids = array();
    foreach ($products as $product) {
    $fbp_pids[] = (int)$product['id'];
    }
    echo "fbq('track', 'Purchase', {\n
    value: " . number_format($order->info['total'], 2, '.', '') . ",\n
    currency: '" . $_SESSION['currency'] . "',\n
    content_type: 'product',\n
    content_ids: ['" . implode("','", $fbp_pids) . "']\n
    });";
    }
    break;

  7. #7
    Join Date
    Jan 2015
    Posts
    726
    Plugin Contributions
    1

    Default Re: PHP Fatal error: Uncaught Error: [] operator not supported for strings

    that work thank you......

 

 

Similar Threads

  1. v155 PHP Fatal error: Uncaught Error: Call to undefined function mysqli_close()
    By Brent in forum Installing on a Linux/Unix Server
    Replies: 2
    Last Post: 2 Apr 2018, 04:03 PM
  2. Replies: 6
    Last Post: 15 Oct 2013, 08:33 PM
  3. [Resolved: operator error] error:10713 Invalid Data (missing country)
    By Lineage in forum PayPal Website Payments Pro support
    Replies: 4
    Last Post: 3 Aug 2010, 05:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg