Automatically add an item to cart

WPPizza – A Restaurant Plugin for WordPress Support General Support Automatically add an item to cart

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #8266
    hanz
    Participant

      Hello,
      I´ve got a problem. I need some code for automatically add to cart.

      E.g.:
      I want buy a pizza. When I add a pizza to cart, program automatically adds the package to cart. When I want buy 2x pizza, program automatically adds the 2x package to cart…

      package = item with price, etc.

      I am looking for some like [wppizza type=’add_item_to_cart_button’ id=’6′] but without button and automatically

      Thanks for help and sorry for my English.

      #8270
      Olly
      Admin & Mod

        php or javascript ?

        #8272
        hanz
        Participant

          php

          #8278
          Olly
          Admin & Mod

            at the moment you’d have to take/copy

            wppizza/ajax/get-json.php

            and use the whole bit

            
            $options=$this->pluginOptions; 
            /*
            you might want to / have to change the above to
            $options=get_option('wppizza'); 
            **/
            global $blog_id;
            /****************************************************************
            *	[add / remove item from cart session]
            ***************************************************************/
            if(isset($_POST['vars']['type']) && (($_POST['vars']['type']=='add' || $_POST['vars']['type']=='remove' || $_POST['vars']['type']=='removeall' || $_POST['vars']['type']=='increment') && $_POST['vars']['id']!='') ||  $_POST['vars']['type']=='refresh' || $_POST['vars']['type']=='wppizza-update-order'){
            /**code**/
            }
            

            and pass the relevant variables to it as the whole thing is only only available via ajax

            one day i might make that whole thing into it’s own class, but for the moment it is what it is

          Viewing 4 posts - 1 through 4 (of 4 total)
          • The topic ‘Automatically add an item to cart’ is closed to new replies.