Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1307484
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionI am using WC()->cart->add_to_cart($new_post_id);
to add a product ,but this function does not adding for the first time when cart is empty.
If I add product using default add to cart button, Then after the above function works properly so can you please point out the issue .
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionI am using WC()->cart->add_to_cart($new_post_id);
to add a product ,but this function does not adding for the first time when cart is empty.
If I add product using default add to cart button, Then after the above function works properly so can you please point out the issue .
Share Improve this question edited Jan 13, 2021 at 12:29 Tom J Nowell♦ 61k7 gold badges79 silver badges148 bronze badges asked Sep 15, 2017 at 8:26 owtowt 991 gold badge1 silver badge6 bronze badges1 Answer
Reset to default 0Quantity is missing of the product try to use
WC()->cart->add_to_cart( $new_post_id , $qty );
where $qty is a number of items you want to add in the cart for a particular product.
hope this will help you.
Thank you.
本文标签: phpAdd to cart function not working for first product when cart is empty
版权声明:本文标题:php - Add to cart function not working for first product when cart is empty 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741838482a2400354.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论