Support » Plugin: WooCommerce added to cart popup (Ajax) » Add to Cart button for Variable product

  • bryan042092

    (@bryan042092)


    Hi,

    I just need the proper button mark up for variable product.

    We were able to add a button for simple product. Example code below.

    <p class="mt-40 mb-0 product woocommerce add_to_cart_inline" style="text-align: center;">
    <a href="?add-to-cart=269" data-quantity="1" class="button product_type_simple add_to_cart_button ajax_add_to_cart" data-product_id="269" data-product_sku="" aria-label="Add “Member Option Standard (Annually)” to your cart" rel="nofollow" style="font-weight: 600;">Join Now</a></p>

    But when I tried that markup on a variable product. I got an issue like the details of the variable products is not recorded on cart and on receipt. https://prnt.sc/pg98gy https://prnt.sc/pg98j9

    Which should be something like this.
    http://prntscr.com/pgowtw

    If you can help us give the proper html markup for variable product please. It would be amazing.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author xootix

    (@xootix)

    Hello @bryan042092

    Unlike simple products, you need to add a variation ID as well.
    This HTML markup would work. All other input elements except add to cart button are hidden.

    <form class="cart">
    <input type="hidden" name="product_id" value="{product_id}">
    <input type="hidden" name="variation_id" value="{variation_id}">
    <input type="hidden" name="qty" value="1">
    <button type="submit" name="add-to-cart" value="{product_id}">Add to Cart</button>
    </form>
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.