2
我設計Woocommerce單品頁, 我設計的產品頁面我創造了這個功能 安排「選擇變異」選擇和「添加到購物車「按鈕安排Woocommerce可變產品數據
function filter_grouped_cart(){
global $post;
if(function_exists('get_product')){
$product = get_product($post->ID);
if($product->is_type('variable')){
remove_action('woocommerce_variable_add_to_cart',
'woocommerce_variable_add_to_cart', 30);
add_action('woocommerce_before_single_product_summary',
'woocommerce_variable_add_to_cart', 45);
remove_action('woocommerce_single_variation',
'woocommerce_single_variation_add_to_cart_button', 20);
add_action('woocommerce_before_single_product_summary',
'woocommerce_single_variation_add_to_cart_button', 60);
}
}
}
我用條件邏輯,因爲沒有它,我簡單的產品頁面什麼也沒有顯示。 此代碼工作正常,但我有這方面的行動和他們的優先
remove_action('woocommerce_before_single_product_summary',
'woocommerce_show_product_images', 20);
add_action('woocommerce_single_product_summary',
'woocommerce_show_product_images', 20);
remove_action('woocommerce_single_product_summary',
'woocommerce_template_single_title', 5);
add_action('woocommerce_before_single_product_summary',
'woocommerce_template_single_title', 30);
remove_action('woocommerce_after_single_product_summary',
'woocommerce_output_product_data_tabs', 10);
add_action('woocommerce_before_single_product_summary',
'the_content', 40);
remove_action('woocommerce_single_product_summary',
'woocommerce_template_single_price', 10);
add_action('woocommerce_before_single_product_summary',
'woocommerce_template_single_price', 50);
remove_action('woocommerce_single_product_summary',
'woocommerce_template_single_add_to_cart', 30);
add_action('woocommerce_before_single_product_summary',
'woocommerce_template_single_add_to_cart', 60);
我想「選擇選項」選擇價格即前
add_action('woocommerce_before_single_product_summary',
'woocommerce_template_single_price', 50);
它的優先級是50 所以,我對於加入優先級45
add_action('woocommerce_before_single_product_summary',
'woocommerce_variable_add_to_cart', 45);
但還是woocommerce_variable_add_to_cart正顯示出以下 woocommerce_template_single_price
在上面的圖片中,如果我有45-50-60,那麼60和50會出現在單行中,45以上的是50,這是我的要求。
是的,這解決了這個問題,對不起,遲交回復。 –
最終改進代碼 https://jsfiddle.net/wasim717/08dj7ey5/ –