Add Ingredients Issue

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #36576
    justin
    Participant

      Hi Olly!

      I’m not sure if this is related but, the last thing we did was install the Add Ingredients & Stripe gateway and configured. When performing a test checkout the order submits, email sends but the checkout doesn’t redirect to the thank you page. The only error I can see is:
      (We are testing only using COD)

      
      error :
      scripts.min.js?ver=3.2.10:1 SyntaxError: Unexpected token A in JSON at position 0
      at JSON.parse (<anonymous>)
      at n.parseJSON (jquery.js?ver=1.12.4:4)
      at a.parseJSON (jquery-migrate.min.js?ver=1.4.1:2)
      at Xb (jquery.js?ver=1.12.4:4)
      at y (jquery.js?ver=1.12.4:4)
      at XMLHttpRequest.c (jquery.js?ver=1.12.4:4)
      

      On a side issue, I can’t seem to locate the extra ingredients to print out. Is it something like $order[‘order’][‘items’][‘extras’]?

      
      foreach($order['order']['items'] as $item) {
      $txt .= "$item[quantity];$item[title];$item[pricetotal_formatted];$item[price_label];";
      }
      

      Thanks again!

      #36578
      Olly
      Admin & Mod

        got a link ?

        #36579
        Olly
        Admin & Mod

          re: On a side issue

          as i dont know where or how you are using it , i cannot really comment other then to say that generally speaking you have to loop through $item[‘extend’][‘addingredients’]

          correction: i believe this is actually $item['extend_data']['addingredients']

          #36594
          justin
          Participant

            Thanks Olly,

            The development site is hosted in the subfolder here: https://seoexpertgoldcoast.com.au/gourmet/

            #36596
            Olly
            Admin & Mod

              just did a test on your site and it works just fine…?!
              any particular items in cart or checkout details you can give me so i can reproduce this ?

              #36598
              justin
              Participant

                Hi Olly,

                Thanks for taking a look 🙂

                I wasn’t aware at the time but it appears only the Pizza’s with add ingredients enabled aren’t progressing to the thank you page. E.g. Atlantic Large 12″

                #36599
                justin
                Participant

                  RE: Side Issue

                  I’m not entirely sure what I’m doing wrong. I have a 3 week old newborn so I’m a tad tired. I can’t seem to print_r the arrays? They appear to just print a single “1” character rather than the array.

                  I was missing

                  
                  , true);
                  
                  
                  // Save Order To TXT File //
                  add_action( 'wppizza_on_order_execute', 'print_order', 1);
                  function print_order($order_id, $order, $print_templates) {
                  //declare new ORDER class and assign order details to var order
                  $order = new WPPIZZA_ORDER();
                  $order = $order->session_formatted();
                  //check if delivery or pickup
                  $pickup_delivery = ($order['ordervars']['order_type']['value_formatted'] == 'For Delivery' ? 1 : 2);
                  //check if order has been paid
                  $order_paid = ($order['ordervars']['payment_method']['value_formatted'] == 'Cash' ? 7 : 6);
                  //add pickup_delivery and order_id to txt file
                  $txt = "#Gourmet*$pickup_delivery*$order_id*";
                  //add each item from order into txt file, including ONE extra option
                  foreach($order['order']['items'] as $item) {
                  $txt .= "$item[quantity];$item[title];$item[pricetotal_formatted];$item[price_label];";
                  foreach($item['extend_data']['addingredients'] as $extra) {
                  $txt .= print_r($item);
                  $txt .= print_r($extra);
                  $txt .= print_r($item['extend_data']);
                  $txt .= print_r($item['extend_data']['addingredients']);
                  $txt .= var_dump($item);
                  $txt .= var_dump($extra);
                  }
                  }
                  //add all other order details into txt file
                  $txt .= "*{$order[summary][delivery_charges][0][label]}*{$order[summary][discount][0][value_formatted]};{$order[summary][total][0][value_formatted]};{$order[ordervars][wp_user_id][value_formatted]};{$order[customer][cname][value]};{$order['customer']['caddress']['value']};{$order[customer][ctel][value]};{$order[ordervars][order_date][value_formatted]};$order_paid;{$order[ordervars][payment_gateway][value]};{$order[customer][ccomments][value]}*{$order[customer][ccustom1][value]};{$order['customer']['cemail']['value']};#\r\n";
                  file_put_contents('/home2/seoexpe1/public_html/orders.txt', $txt, FILE_APPEND);
                  }
                  // Save Order To TXT File //
                  
                  #36600
                  justin
                  Participant

                    @Olly Hi Olly,

                    Please disregard the first issue, it appears to be fixed. Thank you for looking at it!

                    However I’m really struggling to loop through the extra ingredients I’m not familiar with recursive arrays.

                    [order][items][1.3.606.3.2.1|235ea5901ba3ea02a7d748b9b98b644e][extend_data][addingredients][multi][1][0][47]

                    Code so far:

                    
                    // Save Order To TXT File //
                    // Save Order To TXT File //
                    add_action( 'wppizza_on_order_execute', 'print_order', 1);
                    function print_order($order_id, $order, $print_templates) {
                    //declare new ORDER class and assign order details to var order
                    $order = new WPPIZZA_ORDER();
                    $order = $order->session_formatted();
                    //check if delivery or pickup
                    $pickup_delivery = ($order['ordervars']['order_type']['value_formatted'] == 'For Delivery' ? 1 : 2);
                    //check if order has been paid
                    $order_paid = ($order['ordervars']['payment_method']['value_formatted'] == 'Cash' ? 7 : 6);
                    //add pickup_delivery and order_id to txt file
                    $txt = "#Gourmet*$pickup_delivery*$order_id*";
                    //$txt .= print_r($order, true);
                    //add each item from order into txt file, including ONE extra option
                    foreach($order['order']['items'] as $item) {
                    $txt .= "$item[quantity];$item[title]";
                    foreach($item['extend_data']['addingredients']['multi']['1']['0'] as $key => $value) {
                    //$txt .= print_r($value, true);
                    $txt .= " $value[count]x$value[name]";
                    }
                    $txt .= ";$item[pricetotal_formatted];$item[price_label];";
                    }
                    //add all other order details into txt file
                    $txt .= "*{$order[summary][delivery_charges][0][label]}*{$order[summary][discount][0][value_formatted]};{$order[summary][total][0][value_formatted]};{$order[ordervars][wp_user_id][value_formatted]};{$order[customer][cname][value]};{$order['customer']['caddress']['value']};{$order[customer][ctel][value]};{$order[ordervars][order_date][value_formatted]};$order_paid;{$order[ordervars][payment_gateway][value]};{$order[customer][ccomments][value]}*{$order[customer][ccustom1][value]};{$order['customer']['cemail']['value']};#\r\n";
                    file_put_contents('/home2/seoexpe1/public_html/orders.txt', $txt, FILE_APPEND);
                    }
                    // Save Order To TXT File //
                    

                    Outputs:

                    
                    #Gourmet*1*30*1;Atlantic 1 x Bacon 1 x Ham;$ 34.00;Family 15&quot;;*Free Delivery*;$ 34.00;Registered User (#1);Justin;23 daisy road mountain;0400000000;April 8, 2018 5:14 am;7;COD;test*;[email protected];#
                    
                    #36695
                    Olly
                    Admin & Mod

                      Hi
                      sorry about the late reply. git completely snowed under with other things and it got lost in the queue so to speak

                      first of all, as I believe I already mentioned (perhaps), that plugin is in serious need of updating (in fact more or less re-writing) as soon as I get a chance , so what i would suggest – as a starting point – is to make a copy of the function
                      prepare_ingredients_for_markup($post_id, $item, $type) you will find in wppizza-addingredients.php to wherever you need it as – for example myprefix_prepare_ingredients_for_markup($post_id, $item) , omitting the type parameter

                      then at the top of that function add
                      $ai_options = get_option('wppizza_addingredients'); and replace the occurrences of $this->pluginOptions with $ai_options (or whatever you have called it) and pass the $post_id , $item from your loop to that new function you created

                      furthermore, i would also then perhaps replace
                      $showByGroup= (!empty($this->pluginOptions['options']['ingredients_show_groups_in_email']) && $type != 'cart' ) ? true : false;/* to do, by emails / thank you etc only */

                      with a simple
                      $showByGroup = true; or $showByGroup = false; (depending on what output you want) and take it from there

                      Note: none of the above is tested and it’s just an idea here, but should work i would think and should give you some more manageable array you can then use as you see fit

                      hope that helps somewhat

                      #36696
                      justin
                      Participant

                        Thanks Olly! I’ll update our code thank you.

                        While I’ve got you, is there a simple way to add a magnify type hover action to the menu items?

                        #36697
                        Olly
                        Admin & Mod

                          if you are talking about the images there’s an option in wppiza->layout->Menu Item Images “pretty photo”
                          which will open an image in a lightbox kind of thing , other than that , there might be some other plugins that do things like that , but i have no idea

                          #36698
                          justin
                          Participant

                            That’s perfect thanks Olly!

                          Viewing 12 posts - 1 through 12 (of 12 total)
                          • The topic ‘Add Ingredients Issue’ is closed to new replies.