• I built a custom sizing plugin for a client and had things working well before they decided to use your plugin. While I can get it triggered to open, it won’t show any new items added to the cart. For example, the following two code blocks deal with adding a sample to the cart:

    function order_sample_button() {
      if(!is_product()) {
        return;
      }
      ?>
        <button type="button" id="order-sample" class="xoo-wsc-cart-trigger">
          Order $5 Sample
        </button>
      <?php
    }
    $.ajax({
      type: 'POST',
      url: wc_params_custom.ajax_url,
      data: ORDER,
      success: (response) => {
        console.log('response: ', response)
      },
      error: (error) => {
        console.log('error: ', error);
      },
    });

    The ajax lives inside an event listener waiting for a click on the order button. I can get the side cart to pop out by using the class on the button, but nothing gets added to the cart until the page gets refreshed. I’m at a loss to figure out why these two plugins aren’t working together so well.

    Any thoughts? Thanks in advance!

    Note: the two console.log statements simply log out ‘added to cart’ or ‘not added to cart.’ I consistently see ‘added to cart’ in the console every time, just nothing showing in the side cart.

    • This topic was modified 1 year, 1 month ago by jstrother.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author xootix

    (@xootix)

    Hello,

    Sorry for the delayed response.
    You will need to return the cart fragments on “adding to cart”. It requires a little more coding than simply adding to cart.
    Why not use the woocommerce’s inbuilt function for add to cart? This HTML will add to cart with ajax, no extra code required

    ?<a data-quantity="1" class="add_to_cart_button?ajax_add_to_cart" data-product_id="26">Add to cart</a>

    Thread Starter jstrother

    (@jstrother)

    The ‘add to cart’ button on product pages has been removed as the plugin opens a modal to allow customers to size an image to desired dimensions before adding to the cart from the modal. The sizing is required for the client to print to the correct size, so I have to pass the height and width in inches (and the square footage based on them), along with the dimensions the customer initially entered (inches, feet & inches, or centimeters).

    I’ll take a look at how to use your code sample with all of this info that needs to be passed along.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Plugin not Triggering Side Cart Properly’ is closed to new replies.