{"id":17237,"date":"2025-07-23T01:42:48","date_gmt":"2025-07-23T01:42:48","guid":{"rendered":"https:\/\/www.egold.vip\/?p=17237"},"modified":"2025-07-23T05:38:49","modified_gmt":"2025-07-23T05:38:49","slug":"woocommerce%ef%bc%9a%e5%9c%a8%e4%ba%a7%e5%93%81%e8%af%a6%e6%83%85%e9%a1%b5%e4%b8%80%e9%94%ae%e5%ba%94%e7%94%a8%e4%bc%98%e6%83%a0%e5%88%b8","status":"publish","type":"post","link":"http:\/\/testing.egold.vip\/es\/archives\/17237","title":{"rendered":"Woocommerce\uff1a\u5728\u4ea7\u54c1\u8be6\u60c5\u9875\u4e00\u952e\u5e94\u7528\u4f18\u60e0\u5238"},"content":{"rendered":"<p>\u9996\u5148\u770b\u6548\u679c\u56fe\uff1a<\/p><figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.egold.vip\/wp-content\/uploads\/2025\/07\/screenshot-20250304-125410.webp\" alt=\"screenshot\" class=\"wp-image-17238\"\/><\/figure><p>\u5728\u4ea7\u54c1\u8be6\u60c5\u9875\u5b9e\u73b0\u4e00\u4e2a\u5355\u9009\u6846\uff08Checkbox\uff09\u6765\u4e00\u952e\u5e94\u7528\u4f18\u60e0\u5238\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\uff1a<\/p><h2 class=\"wp-block-heading\">1.\u521b\u5efa\u4f18\u60e0\u5238<\/h2><p>\u767b\u5f55\u5230 WordPress \u540e\u53f0\uff0c\u5bfc\u822a\u5230 WooCommerce > \u4f18\u60e0\u5238\uff0c\u70b9\u51fb\u201c\u6dfb\u52a0\u4f18\u60e0\u5238\u201d\uff0c\u8bbe\u7f6e\u4f18\u60e0\u5238\u4ee3\u7801\u3001\u6298\u6263\u7c7b\u578b\u3001\u91d1\u989d\u7b49\u8be6\u7ec6\u4fe1\u606f\uff0c\u4fdd\u5b58\u4f18\u60e0\u5238\u3002<\/p><h2 class=\"wp-block-heading\">2.\u5728\u4ea7\u54c1\u8be6\u60c5\u9875\u6dfb\u52a0\u5355\u9009\u6846\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u81ea\u5b9a\u4e49\u4ee3\u7801\u6765\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\uff0c\u4ee5\u4e0b\u662f\u4f7f\u7528\u81ea\u5b9a\u4e49\u4ee3\u7801\u7684\u793a\u4f8b<\/h2><pre class=\"wp-block-preformatted\">\/\/Apply Coupon From Add to Cart @ Woo Single Product\nfunction add_coupon_radio_button() {\n    echo '&lt;div style=\"clear:both\"&gt;&lt;br&gt;&lt;p&gt;&lt;label for=\"apply_coupon\"&gt;&lt;input type=\"checkbox\" id=\"apply_coupon\" name=\"add_coupon\"&gt; Apply a 10% discount!&lt;\/label&gt;&lt;\/p&gt;';\n}\nadd_action( 'woocommerce_after_add_to_cart_button', 'add_coupon_radio_button', 10 );\nfunction apply_coupon_on_checkbox_clicked( $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data ) {\n    if ( isset( $_POST['add_coupon'] ) ) {\n         $coupon_code = 'nqn59yka'; \/\/ YOUR COUPON CODE\n         WC()-&gt;cart-&gt;apply_coupon( $coupon_code );\n    }\n}\nadd_action( 'woocommerce_add_to_cart', 'apply_coupon_on_checkbox_clicked', 10, 6 );<\/pre><p>\u6ce8\u610f\uff1a\u5c06 YOUR_COUPON_CODE \u66ff\u6362\u4e3a\u4f60\u81ea\u5df1\u7684\u4f18\u60e0\u5238\u4ee3\u7801\u3002\u5c06\u4e0a\u8ff0\u4ee3\u7801\u6dfb\u52a0\u5230\u6a21\u677f\u76ee\u5f55\u4e0b\u9762\u7684functions.php\u6587\u4ef6\uff0c\u6ce8\u610f\u63d0\u524d\u505a\u597d\u5907\u4efd\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148\u770b\u6548\u679c\u56fe\uff1a \u5728\u4ea7\u54c1\u8be6\u60c5\u9875\u5b9e\u73b0\u4e00\u4e2a\u5355\u9009\u6846\uff08Checkbox\uff09\u6765\u4e00\u952e\u5e94\u7528\u4f18\u60e0\u5238\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\uff1a 1.\u521b\u5efa\u4f18\u60e0\u5238 \u767b\u5f55\u5230 WordPress \u540e\u53f0\uff0c\u5bfc\u822a\u5230 WooCommerce > \u4f18\u60e0\u5238\uff0c\u70b9\u51fb\u201c\u6dfb\u52a0\u4f18\u60e0\u5238\u201d\uff0c\u8bbe\u7f6e\u4f18\u60e0\u5238\u4ee3\u7801\u3001\u6298\u6263\u7c7b\u578b\u3001\u91d1\u989d\u7b49\u8be6\u7ec6\u4fe1\u606f\uff0c\u4fdd\u5b58\u4f18\u60e0\u5238\u3002 2.\u5728\u4ea7\u54c1\u8be6\u60c5\u9875\u6dfb\u52a0\u5355\u9009\u6846\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u81ea\u5b9a\u4e49\u4ee3\u7801\u6765\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\uff0c\u4ee5\u4e0b\u662f\u4f7f\u7528\u81ea\u5b9a\u4e49\u4ee3\u7801\u7684\u793a\u4f8b \/\/Apply Coupon From Add to Cart @ Woo Single Product function add_coupon_radio_button() { echo &#8216;&lt;div style=&#8221;clear:both&#8221;&gt;&lt;br&gt;&lt;p&gt;&lt;label for=&#8221;apply_coupon&#8221;&gt;&lt;input type=&#8221;checkbox&#8221; id=&#8221;apply_coupon&#8221; name=&#8221;add_coupon&#8221;&gt; Apply a 10% discount!&lt;\/label&gt;&lt;\/p&gt;&#8217;; } add_action( &#8216;woocommerce_after_add_to_cart_button&#8217;, &#8216;add_coupon_radio_button&#8217;, 10 ); function apply_coupon_on_checkbox_clicked( $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data ) { if ( isset( $_POST[&#8216;add_coupon&#8217;] ) [&hellip;]<\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[301],"tags":[],"acf":[],"_links":{"self":[{"href":"http:\/\/testing.egold.vip\/es\/wp-json\/wp\/v2\/posts\/17237"}],"collection":[{"href":"http:\/\/testing.egold.vip\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/testing.egold.vip\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/testing.egold.vip\/es\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"http:\/\/testing.egold.vip\/es\/wp-json\/wp\/v2\/comments?post=17237"}],"version-history":[{"count":0,"href":"http:\/\/testing.egold.vip\/es\/wp-json\/wp\/v2\/posts\/17237\/revisions"}],"wp:attachment":[{"href":"http:\/\/testing.egold.vip\/es\/wp-json\/wp\/v2\/media?parent=17237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/testing.egold.vip\/es\/wp-json\/wp\/v2\/categories?post=17237"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/testing.egold.vip\/es\/wp-json\/wp\/v2\/tags?post=17237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}