Skip to content

Instantly share code, notes, and snippets.

@nczz
Last active July 1, 2019 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nczz/96ba05062531468f754b8f0cd449f876 to your computer and use it in GitHub Desktop.
Save nczz/96ba05062531468f754b8f0cd449f876 to your computer and use it in GitHub Desktop.
結帳頁面顯示運費計算功能 https://www.mxp.tw/8550/
<?php
function action_woocommerce_before_checkout_form($wccm_autocreate_account) {
wc_cart_totals_shipping_html();
woocommerce_shipping_calculator('選取運送方式');
};
add_action('woocommerce_before_checkout_form', 'action_woocommerce_before_checkout_form', 10, 1);
function woocommerce_shipping_calculator_scripts() {
if (is_checkout()) {
if (wp_script_is('wc-cart', 'registered') && !wp_script_is('wc-cart', 'enqueued')) {
wp_enqueue_script('wc-cart');
}
}
}
add_action('wp_enqueue_scripts', 'woocommerce_shipping_calculator_scripts');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment