Multi Price 商品をカートに入れた数だけ割引する方法

フォーラム 拡張プラグイン Multi Price 商品をカートに入れた数だけ割引する方法

  • このトピックには3件の返信、3人の参加者があり、最後にmiyaにより6年、 4ヶ月前に更新されました。
4件の投稿を表示中 - 1 - 4件目 (全4件中)
  • 投稿者
    投稿
  • #84698
    miya
    参加者

    カートに入れられた商品の数に対して割引を設定したいのですが、やりかたがわかりません。

    例えば「商品1」「商品2」「商品3」「商品4」「商品5」5つの商品がカートに入れられた場合合計の数値を10%引きにしたいです。また同じ商品5つカートに入れられた場合も同じように10%引きで、数に応じで割引する数値を大きくしたいです。

    Multi Priceの設定でできるのでしょうか?わかる方教えてください。

    #84706
    yskysmr
    キーマスター

    こんにちは。

    WCEX Multi Price では、ご要望通りの仕様は実現できません。独自にカスタマイズすれば可能かと思います。

    #84742
    Gen6
    参加者
    add_filter('usces_order_discount', 'sku_order_discount', 10, 3);
    function sku_order_discount($discount, $carts, $entries){
        global $usces;
        $total = $usces->get_total_quantity( $cart );
        if ( ($total >= 2) && ($total < 3) ) {
        $discount = -5000;
        }
        if ( ($total >= 3) && ($total <= 4) ) {
        $discount = -7500;
        }
        return $discount;
    }

    このようにfunctions.phpに書き込んで数量別の割引を仕込んではどうでしょうか。

    #84744
    miya
    参加者

    ありがとうございます。最終的にこのような形でカート内の数で割引することが出来ました。

    
    function item_count_order_discount($discount, $carts,$entries) {
        global $usces;
        $total = $usces->get_total_quantity($cart);
        $total_items_price = $usces->get_total_price();
        if (($total >= 2) && ($total <= 4)) {
            $discount = ceil($total_items_price * 0.15 *-1);
        }
        if (($total >= 4) && ($total <= 7)) {
            $discount = ceil($total_items_price * 0.2 *-1);
        }
        return $discount;
    }
    
    add_filter('usces_order_discount', 'item_count_order_discount', 10, 3);
    
    • この返信は6年、 4ヶ月前にmiyaが編集しました。
4件の投稿を表示中 - 1 - 4件目 (全4件中)
  • このトピックに返信するにはログインが必要です。