Skip Navigation

[Resolved] Woocommerce add to cart button field not rendering when rendering via ajax

This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by markD-13 7 years ago.

Assisted by: Beda.

Author
Posts
#515858

I am trying to:
load a single product view into a MagnificPopup via ajax

I visited this URL:
on localhost

I expected to see:
the add to cart button and variation selector

Instead, I got:
blank div where add to cart stuff should go

If i create a custom shortcode and render the output from the woocommerce add-to-cart shortcode

e.g.

function db_add_to_cart($atts) {
$id = $atts['id'];
ob_start();
echo do_shortcode('[add_to_cart id="'.$id.'"]');
$myStr = ob_get_contents();
ob_end_clean();
return $myStr;

}

it kind of works but i want the same output as the view outputs if rendered normally i.e. not via ajax.

Please help point me in the right direction.

#516014

There si a similar thread about Add to Cart and AJAX:
https://toolset.com/forums/topic/ajax-not-working-without-quantity-selector-when-product-is-added-to-cart/

But I am not sure you experience the same issue.

Might you provide me a Site's Snapshot, if this is not the same issue, with all links to the relevant Screens and Code, so I could analyse this locally?

Here are the instructions on how to provide me a snapshot:
https://toolset.com/faq/provide-supporters-copy-site/

#517026

Hi Beda,

I managed to resolve it by rendering a full single product page via magnific popup ajax method (instead of calling a function in my theme via ajax), and then filtering out everything not within the body tags using jquery in the magnific popup callbacks.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.