[英]add meta to a product on cart WooCommerce
i'm trying to add product to the cart via PHP using this code,我正在尝试使用此代码通过 PHP 将产品添加到购物车,
$woocommerce->cart->add_to_cart(20);
the product is getting into the cart but i would like to add custom meta as shown on the image but i want to do that via PHP and not the backend该产品正在进入购物车,但我想添加如图所示的自定义元数据,但我想通过 PHP 而不是后端来做到这一点
So after bit of reading throughout the code.所以在阅读了整个代码之后。 I've found this
我找到了这个
$woocommerce->cart->add_to_cart($product, $quantity, $variation, array('foo'=>'bar') );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.