{"id":528885,"date":"2021-11-02T20:24:23","date_gmt":"2021-11-02T12:24:23","guid":{"rendered":"https:\/\/loyseo.com\/code-snippet\/woocommerce%ef%bc%9a%e5%9c%a8%e8%b3%bc%e7%89%a9%e8%bb%8a%e5%92%8c%e7%b5%90%e7%ae%97%e9%a0%81%e9%9d%a2%e9%a1%af%e7%a4%ba%e6%89%80%e8%b3%bc%e7%94%a2%e5%93%81%e7%b8%bd%e9%87%8d%e9%87%8f\/"},"modified":"2023-08-25T14:39:49","modified_gmt":"2023-08-25T06:39:49","slug":"woocommerce-display-weight-cart-checkout","status":"publish","type":"code-snippet","link":"https:\/\/loyseo.com\/zh-hant\/code-snippet\/woocommerce-display-weight-cart-checkout\/","title":{"rendered":"WooCommerce\uff1a\u5728\u8cfc\u7269\u8eca\u548c\u7d50\u7b97\u9801\u9762\u986f\u793a\u6240\u8cfc\u7522\u54c1\u7e3d\u91cd\u91cf"},"content":{"rendered":"\n<p>  \u5728\u4f7f\u7528<a href=\"https:\/\/loyseo.com\/zh-hant\/tutorial\/woocommerce\/\">WooCommerce<\/a>\u7684\u8de8\u5883\u96fb\u5546\u7368\u7acb\u7ad9\u4e2d\uff0c\u5982\u679c\u4f60\u60f3\u5728\u8cfc\u7269\u8eca\u548c\u7d50\u7b97\u9801\u9762\u5411\u5ba2\u6236\u5c55\u793a\u5b83\u6240\u52a0\u8cfc\u7684\u7522\u54c1\u7684\u7e3d\u91cd\u91cf\uff0c\u90a3\u9ebc\uff0c\u53ef\u4ee5\u5728<a href=\"https:\/\/loyseo.com\/code-snippet\/\" data-type=\"post\" data-id=\"503384\">Code snippet<\/a>\u5916\u639b\u7a0b\u5f0f\u4e2d\u63d2\u5165\u4e0b\u9762\u7684php\u4ee3\u78bc\u6bb5\uff0c\u4e0d\u9700\u8981\u4efb\u4f55\u984d\u5916\u5916\u639b\u7a0b\u5f0f\u5c31\u80fd\u5be6\u73fe\u9019\u500b\u529f\u80fd\uff0c\u771f\u68d2\u68d2~  <\/p>\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"505\" src=\"https:\/\/loyseo.com\/wp-content\/uploads\/2021\/11\/woocommerce-display-weight-cart-checkout.png\" alt=\"\" class=\"wp-image-513380\" title=\"-\"><\/figure>\n\n<p>\u4ee3\u78bc\u5982\u4e0b\uff1a<\/p>\n\n<pre class=\"wp-block-code\"><code>\n\nadd_action( 'woocommerce_before_checkout_form', 'bbloomer_print_cart_weight' );\nadd_action( 'woocommerce_before_cart', 'bbloomer_print_cart_weight' );\n  \nfunction bbloomer_print_cart_weight() {\n   $notice = 'Your cart weight is: ' . WC()-&gt;cart-&gt;get_cart_contents_weight() . get_option( 'woocommerce_weight_unit' );\n   if ( is_cart() ) {\n      wc_print_notice( $notice, 'notice' );\n   } else {\n      wc_add_notice( $notice, 'notice' );\n   }\n}\n\n<\/code><\/pre>\n\n<p>\u8aaa\u660e\uff1a\u6211\u5728\u4f7f\u7528\u9019\u500b\u4ee3\u78bc\u6bb5\u540e\uff0c\u5728\u9801\u9762\u4e0a\u770b\u5230\u91cd\u91cf\u8cc7\u8a0a\u6642\uff0c\u9801\u9762\u4f48\u5c40\u6709\u9ede\u932f\u4e82\uff0c\u9019\u500b\u6642\u5019\u9700\u8981\u6709\u4e00\u9edeCSS\u4ee3\u78bc\u77e5\u8b58\uff0c\u9019\u500b\u61c9\u8a72\u8ddf\u4e3b\u984c\u5916\u639b\u7a0b\u5f0f\u7684\u4f7f\u7528\u6709\u95dc\uff0c\u6240\u4ee5\u6b64\u8655\u6211\u6c92\u8fa6\u6cd5\u7d66\u51fa\u4e00\u500b\u7d71\u4e00\u7684\u7b54\u6848\u3002<\/p>\n\n<p>\u5728woodmart\u4e3b\u984c\u4e2d\uff0c\u6211\u5728\u4e3b\u984c\u7684custom css\u4e2d\u65b0\u589e\u4e86\u5982\u4e0b\u4ee3\u78bc\u4f86\u89e3\u6c7a\u5e03\u5c40\u7684\u554f\u984c\u3002<\/p>\n\n<pre class=\"wp-block-code\"><code>.woocommerce-info\r\n{width:100%;\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4f7f\u7528WooCommerce\u7684\u8de8\u5883\u96fb\u5546\u7368\u7acb\u7ad9\u4e2d\uff0c\u5982\u679c\u4f60\u60f3\u5728\u8cfc\u7269\u8eca\u548c\u7d50\u7b97\u9801\u9762\u5411\u5ba2\u6236\u5c55\u793a\u5b83\u6240\u52a0\u8cfc\u7684\u7522\u54c1\u7684\u7e3d\u91cd\u91cf\uff0c\u90a3\u9ebc\uff0c\u53ef\u4ee5\u5728Code snippet\u5916\u639b\u7a0b\u5f0f\u4e2d\u63d2\u5165\u4e0b\u9762\u7684php\u4ee3\u78bc\u6bb5\uff0c\u4e0d\u9700\u8981\u4efb\u4f55\u984d\u5916\u5916\u639b\u7a0b\u5f0f\u5c31\u80fd\u5be6\u73fe\u9019\u500b\u529f\u80fd\uff0c\u771f\u68d2\u68d2~ \u4ee3\u78bc\u5982\u4e0b\uff1a \u8aaa\u660e\uff1a\u6211\u5728\u4f7f\u7528\u9019\u500b\u4ee3\u78bc\u6bb5\u540e\uff0c\u5728\u9801\u9762\u4e0a\u770b\u5230\u91cd\u91cf\u8cc7\u8a0a\u6642\uff0c\u9801\u9762\u4f48\u5c40\u6709\u9ede\u932f\u4e82\uff0c\u9019\u500b\u6642\u5019\u9700\u8981\u6709\u4e00\u9edeCSS\u4ee3\u78bc\u77e5\u8b58\uff0c\u9019\u500b\u61c9\u8a72\u8ddf\u4e3b\u984c\u5916\u639b\u7a0b\u5f0f\u7684\u4f7f\u7528\u6709\u95dc\uff0c\u6240\u4ee5\u6b64\u8655\u6211\u6c92\u8fa6\u6cd5\u7d66\u51fa\u4e00 [&hellip;]<\/p>\n","protected":false},"featured_media":0,"template":"","class_list":["post-528885","code-snippet","type-code-snippet","status-publish","hentry"],"acf":[],"taxonomy_info":[],"featured_image_src_large":false,"author_info":[],"comment_info":"","_links":{"self":[{"href":"https:\/\/loyseo.com\/zh-hant\/wp-json\/wp\/v2\/code-snippet\/528885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/loyseo.com\/zh-hant\/wp-json\/wp\/v2\/code-snippet"}],"about":[{"href":"https:\/\/loyseo.com\/zh-hant\/wp-json\/wp\/v2\/types\/code-snippet"}],"wp:attachment":[{"href":"https:\/\/loyseo.com\/zh-hant\/wp-json\/wp\/v2\/media?parent=528885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}