Woocommerce variation product - Ajax


I have having a small issue with woocommerce_template_single_add_to_cart().

Although it works fine with normal html form submit for all kinds of products ( simple, variable, grouped, etc), it won't work when I switch it to Ajax call.

AJAX call:

add_action('wp_ajax_CP_single', 'CP_single');

function CP_single(){


echo "<div>";

echo '<div style="padding:10px; border: 1px solid #DEE2E3; text-align:center;" >';

global $product;

$product = get_product($_POST['p_id']);

$post = $product->post;

echo get_the_title($post->ID)."<hr />";

if (has_post_thumbnail( $post->ID ) ){

$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );

echo '<img style="width:200px; " src="'.$image[0].'">';



echo "</div>";

echo "</div>";




I have populated products in a div, and onclick it send p_id as POST to ajax call, and is suppose to show the ajax-success-data on a popup (ie. the add-to-cart button).

It does fine for "Simple" product, but won't show the "add-to-cart" button for Variable products.

Why ?? and can you help?

Habilidades: PHP, Arquitetura de software, WordPress

Veja mais: it works global, call center products, button onclick php, add padding to image, solid works software, simple woocommerce, add products on woocommerce, add product woocommerce, woocommerce change product variation, image div show, php popup form ajax, html woocommerce single product, simple solid works, php global variable, woocommerce single product, woocommerce php grouped products, woocommerce product variation image, woocommerce ajax, woocommerce variable product, product add woocommerce, grouped product, woocommerce product variation custom field, woocommerce variable products, woocommerce ajax product filter, woocommerce add product cart ajax

Acerca do Empregador:
( 26 comentários ) Dublin, Ireland

ID do Projeto: #6823542

Concedido a:


Hello Sir, I understand why this issue is occuring. Its definitely because of the varible product. I cannot disclose everything out here as this is a small budget project. Kindly contact, I am sure to fix this, Mais

€21 EUR em 1 dia
(68 Comentários)

4 freelancers estão ofertando em média €34 para esse trabalho


Hi Got ur issue.. I think u need to add some JavaScript that copies the quantity across to the add-to-cart button when it changes. And also i need to see filter hooks to intercept and modify bits of the purchase Mais

€53 EUR in 2 dias
(131 Comentários)

A proposal has not yet been provided

€38 EUR em 1 dia
(19 Comentários)

A proposal has not yet been provided

€23 EUR em 1 dia
(43 Comentários)

Hey, I have an exp of 4.5yrs in Wordpress. I can help you in this . Please share ftp detail. Its an easy task. Thanks

€23 EUR em 1 dia
(0 Comentários)