显示WooCommerce“添加到购物车”用短号[add_to_cart]动态的按钮
我在WordPress网站上的小部件侧边栏中使用WooCommerce短号[add_to_cart]在产品页面上显示“添加到购物车”按钮(想要将短代码放在自定义字段中)。我了解如何使用产品“ ID”在特定页面上显示按钮(例如:[ADD_TO_CART ID =“ 1874”]),但是当它自动获得当前产品页面的ID时,我想这样做(动态)并显示与每个产品页面特定产品相关的“添加到购物车”按钮。有人可以建议如何做吗?
谢谢
I use WooCommerce short-code [add_to_cart ] inside a widget sidebar On WordPress website to display “Add to cart” button on product pages (wanted to put the short-code to Custom Field). I understand how to display the button on a specific page using a product “Id” (for example: [add_to_cart id="1874" ]), but I wanted to make it that way when it gets Id of a current product page automatically (dynamically) and display “Add to cart” button related to a specific product for each product page. Can someone advise how to do it, please?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将以下nipet放在您的函数中
首先,我们需要扩展WP_Widget类
,然后我们需要注册我们的小部件
Place the following snipet in your functions.php
First we need to extend WP_Widget class
After that we need to register our widget