wordpress - Woocommerce Add Product To Cart Multiple Times But As Different items -


I have some custom code that adds an item to the cart, a variable product. If I add the same product twice, then this volume increases. I want to add the product again as a separate item in the cart.

How would I go about doing this? The item is being added to the cart like domain.com?add-to-cart=3434&variation_id=4434 and using similar links.

The system I developed is a product designer. That's why I want to choose the same product but I can design it in different ways, and then add only one change in the car.

Is there a way to send a unique identifier to the URL to split these items up?

I want to do this using add_to_cart, but every time I do this with variation characteristics, shipping ends with a bug, it can not basically find shipping methods :

$ woocommerce-> Cart- & gt; Add_to_cart (5221, 523, array ("attribute_colour" = & gt; "color", "attribute_size" => gt; "A3", "attribute_wine-ranking" = & gt; "yes", "attribute_contact-column "= & Gt;" yes "," attribute_cc-type "= & gt;" duplicate "));

When adding that item to the cart, it causes the following:

WARNING: invalid argument for / home / **** in foreach () Given is line 291 on /public_html/wp-content/plugins/woocommerce/includes/class-wc-shipping.php

There are no available shipping methods. Please check your address again, or contact us if you need any help.

This does not make any sense because the cart code in woocommerce uses the standard add_to_cart and does not have any of these problems. If I use the same URL, it works fine!

Try it out!

DCC Individual Cart Item Force / Function force_indilize_tits ($ cart_item_data, $ product_id) {$ unique_cart_item_key = md5 (microgram (). Rand ()); $ Cart_item_data ['unique_key'] = $ unique_cart_item_key; Return $ cart_item_data; } Add_filter ('woocommerce_add_cart_item_data', 'force_individual_cart_items', 10, 2); / * * @ DCC Remove the quantity selector in all product types * / function remove_all_quantity_fields ($ return, $ product) {return true; } Add_filter ('woocommerce_is_sold_individually', 'remove_all_quantity_fields', 10, 2);

Comments