2014-04-09 113 views

回答

3

在功能文件,請執行下列操作:

  1. 刪除「原始」 upsale顯示

    remove_action('woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15); 
    remove_action('woocommerce_after_single_product_summary', 'woo_wc_upsell_display', 15); 
    
  2. 添加由順序排序的自定義追加銷售顯示你添加的產品在管理界面中

    add_action('woocommerce_after_single_product_summary', 'custom_wc_upsell_display', 15); 
    
    if (!function_exists('custom_wc_upsell_display')) { 
        function custom_wc_upsell_display() { 
         woocommerce_get_template('single-product/up-sells.php', array(
          'posts_per_page' => -1, 
          'orderby' => 'post__in', 
          'columns' => 3 
         )); 
        } 
    } 
    

實際情況是,在向上銷售模板中,args-array與各種其他參數(如post_type等)互補,其中一個參數是post__in參數。該模板已經使用了以正確的順序獲取銷售產品ID的函數,然後通過使用post__in參數來使用這個ID數組來限制結果。

訣竅是使用這個已經存在的信息。通過將orderby參數設置爲'post__in',查詢將遵循post__in參數中給出的順序!

相關問題