Advertisement
cloudtuts

Woocommerce romove address-i18n.js

Aug 2nd, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. /*
  2.  * 以下為註解與日期
  3.  * 2017.07.06
  4.  * 移除 address-i18n.js ( /wp-contnet/plugins/woocommerce/assets/js/frontend/address-i18n.js )
  5.  * 移除 address-i18n.js,避免因為這個 js 造成 custom checkout field 無效只會讀取 WooCommerce 預設排序的問題
  6.  * 註銷 cart 與 checkout 的 register ( 因為這兩組帶有 address-i18n 的參數 ) 然後重新註冊不帶 address-i18n 的 cart 與 checkout
  7.  * 這樣一來可以維持 cart form 與 checkout form 的 reload,而 reload 也不會再受 address-i18n 的影響
  8.  */
  9.  
  10. add_action('wp_enqueue_scripts', 'CW_DeregisterScript', 9999);
  11.  
  12. function CW_DeregisterScript(){
  13.  
  14.     $suffix=defined('SCRIPT_DEBUG')&&SCRIPT_DEBUG?'':'.min';
  15.  
  16.     wp_deregister_script('wc-cart');
  17.     wp_deregister_script('wc-checkout');
  18.     wp_deregister_script('wc-address-i18n');
  19.  
  20.     wp_register_script(
  21.         'wc-cart',
  22.  
  23.         /*
  24.          * Fatal error: Uncaught Error: Call to private method WC_Frontend_Scripts::get_asset_url() from context
  25.          */
  26.         //WC_Frontend_Scripts::get_asset_url('assets/js/frontend/checkout'.$suffix.'.js'),
  27.         get_site_url().'/wp-content/plugins/woocommerce/assets/js/frontend/checkout'.$suffix.'.js',
  28.  
  29.         array('jquery', 'woocommerce', 'wc-country-select'));
  30.  
  31.     wp_register_script(
  32.         'wc-checkout',
  33.  
  34.         /*
  35.          * Fatal error: Uncaught Error: Call to private method WC_Frontend_Scripts::get_asset_url() from context
  36.          */
  37.         //WC_Frontend_Scripts::get_asset_url('assets/js/frontend/cart'.$suffix.'.js'),
  38.         get_site_url().'/wp-content/plugins/woocommerce/assets/js/frontend/cart'.$suffix.'.js',
  39.  
  40.         array('jquery', 'woocommerce', 'wc-country-select'));
  41.  
  42.     wp_enqueue_script('wc-cart');
  43.     wp_enqueue_script('wc-checkout');
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement