[英]add product to cart in woocommerce from outside Wordpress
i've figured out that is possible to add a product to cart with these lines: 我已经发现可以通过以下行将产品添加到购物车:
global $woocommerce; $woocommerce->cart->add_to_cart($product_id);
My question is, how to add a product to cart from outside? 我的问题是,如何从外部将产品添加到购物车? I have a simple php site, just want to delegate the sales to wordpress/woocommerce.
我有一个简单的php网站,只想将销售委托给wordpress / woocommerce。 Can i do it with the Api?
我可以用Api做到吗? Can you point me in th right direction?
你能指出我正确的方向吗?
If you want to add a product to the cart from outside of wordpress you can simply add a query on the end of your url, it will need to look like this: 如果您想从wordpress外部将产品添加到购物车,则只需在网址末尾添加一个查询,它将看起来像这样:
http://YOURWEBSITE/?add-to-cart=PRODUCTID http:// YOURWEBSITE /?add-to-cart = PRODUCTID
where PRODUCTID
is the id of the product you want to add to your cart. 其中
PRODUCTID
是您要添加到购物车的产品的ID。
I hope this helps? 我希望这有帮助?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.