WooCommerce:更改加售次数并将其移动到选项卡上方

< 1 min read

如果您在产品页面上使用完整的页面宽度,则可能需要将加售数量更改为3(或多个)。另外,我的客户需要将加售价格设置在选项卡上方。

仿牌独立站出海专家


// ---------------------------
// 1. Remove Upsells From Their Default Position
// NOTE: please make sure your theme is not already overriding this...
// ...for example, see specific Storefront Theme snippet below
 
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
 
// ---------------------------
// 2. Echo Upsells In Another Position
 
add_action( 'woocommerce_after_single_product_summary', 'bbloomer_woocommerce_output_upsells', 5 );
 
function bbloomer_woocommerce_output_upsells() {
woocommerce_upsell_display( 3,3 ); // Display max 3 products, 3 per row
}
}