我在網上找到的很多問答都是關于增加你可以在 woocommerce 變數產品上做出的變化的數量,但我試圖將數量限制在 30。原因是在我做過的一些客戶網站上,他們有像超過 1000 種變化,這使得產品需要一段時間才能加載。我正在創建一個多供應商網站,所以我試圖從一開始就防止有問題的產品。我嘗試過的一些功能是:
add_filter( 'woocommerce_ajax_variation_threshold', 'ww_ajax_variation_threshold', 10, 2 );
function ww_ajax_variation_threshold( $default, $product ) {
return 30;
}
并且
function wpse_rest_batch_items_limit( $limit ) {
$limit = 30;
return $limit;
}
add_filter( 'woocommerce_rest_batch_items_limit', 'wpse_rest_batch_items_limit' );
不幸的是,這些似乎對我不起作用。我還想嘗試在變體彈出訊息中復制它。(見下文)

有誰知道這樣的事情是否可能?
uj5u.com熱心網友回復:
如果要在管理區域中為“每次添加”添加限制,請在其中添加define(WC_MAX_LINKED_VARIATIONS,30)常量,wp-config.php您提到的彈出視窗將自動顯示此數字。但考慮到它只是創建時間的界面限制,不會限制用戶可以在產品上構建的總變化。
uj5u.com熱心網友回復:
有30 個變化的截止點。
僅從 AJAX 上的這個數字接管加載資料。
add_filter( 'woocommerce_ajax_variation_threshold', 'ww_ajax_variation_threshold', 10, 2 );
function ww_ajax_variation_threshold( $default, $product ) {
return 31; // > 30
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/342798.html
標籤:php WordPress的 求购
