Hi Anthony
I’m not sure if I correctly understand the problem
When adding item to cart from wishlist, plugin will add variation directly
For this reason, when you check $cart_item['data']
you should find an instance of WC_Product_Variation
class
From this object you can retrieve attributes for current variation, if you need to use them in some custom template
Hi @yithemes ,
Thank you for your answer.
Here is the result with a screen : Screen
The first product is added from wishlist. The second one is added from the product page.
It sounds like when I add a product to the cart from your wishlist shortcode, the code :
echo wc_get_formatted_cart_item_data( $cart_item );
on cart page doesn’t display anything.
If I print_r() the array, for the product from your wishlist I got this :
Array ( [key] => 7c848f1339c9fb702f94f7e432694a38 [product_id] => 2016 [variation_id] => 2029 [variation] => Array ( ) [quantity] => 1 etc...
And for the product from the product page I got this :
Array ( [key] => 40c03583b67e8dbfc860a48cc6ac1723 [product_id] => 2016 [variation_id] => 2029 [variation] => Array ( [attribute_pa_sexe] => femme [attribute_pa_couleur] => bleu [attribute_pa_taille] => xs ) [quantity] => 1 etc...
The only difference between both array is that in the first case, $cart_item[variation] is empty…
I think the problem come from this empty $cart_item[variation].
If you have any idea to help me fixing this problem…I take it 🙂
-
This reply was modified 4 years ago by nartoof.
Hi again
Thank you for clarifying
I’ve performed a specific test on my installation, but unfortunately I wasn’t able to reproduce the issue
Check my screen: first item was added from wishlist, while second was added directly from product page
I printed 'variation'
index for both items, and, as you can see, they seem to be correctly populated
Thank you for your answer.
It seems like the problem comes from my settings.
I’ll check it.
Thanks again.
Have a nice day.
Anthony
Hi Anthony
I haven’t heard back from you in a while, so I’ll mark this topic as solved
Please, let me know if you need further assistance on this topic: I’ll be happy to help
Hi @yithemes ,
I’m coming back to you on this topic because I really can’t find where the problem comes from.
I can’t find the method you use to add the product to the cart and store it into the global $woocommerce when user click on this add to cart button from the wishlist page :
<a href="https://www.tshirtsinventory.com/panier/?add-to-cart=2152&remove_from_wishlist_after_add_to_cart=2152&wishlist_id=1&wishlist_token=ADFUONDDHZG9" data-quantity="1" class="button add_to_cart_button ajax_add_to_cart add_to_cart alt" data-product_id="2152" data-product_sku="" aria-label="Ajouter “Call My Dealer 4” à votre panier" rel="nofollow">Add to cart</a>
Could you explain to me the method ? PHP or AJAX ?
Which files are used ?
I can’t find any call to any add_to_cart feature in your source code…
I really need to understand because when the final function is called :
public function add_to_cart( $product_id = 0, $quantity = 1, $variation_id = 0, $variation = array(), $cart_item_data = array() )
$variation is still an empty array() for me.
Then I got more bug when in this function it calls generate_cart_id() function who is made with the $variation array.
Then if I add the same product with the same variation from the wishlist, or from the product page, woocommerce display it as 2 differents products.
Anyway, I really would like to know the process / files / functions you use after clicking the add to cart button.
It’s not just a displaying issue…
Thank you very much for your help 🙂
Anthony
-
This reply was modified 3 years, 11 months ago by nartoof.
-
This reply was modified 3 years, 11 months ago by nartoof.
Hi,
I have the same problem. Did you find any solution?
Thank you.
Hi @galenashop ,
I didn’t find any solution right now, still working on it…