バージョン選択

フォーラム

メニュー

オンライン状況

61 人のユーザが現在オンラインです。 (52 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 61
もっと...

サイト内検索

質問 > フロント機能 > 1種類の商品しかカートに入れられないようにする

フロント機能

新規スレッドを追加する

スレッド表示 | 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
aiueokashi
投稿日時: 2015/3/29 16:50
対応状況: −−−
新米
登録日: 2015/3/29
居住地:
投稿: 1
1種類の商品しかカートに入れられないようにする
ECキューブで、1種類の商品しかカートに入れられないようにすることはできますか?
事情があり、カートには1種類の商品しか入れられないようにする必要がでてきました。
「販売制限数」という項目がありますが、こちらは各商品ごとの購入個数なので、違うと思います。

商品Aがカートに入っている場合は、商品Bや商品Cをカートに入れることができないなどの処理ができましたら方法を教えて頂けませんでしょうか。

宜しくお願いいたします。
yuh
投稿日時: 2015/3/29 17:09
対応状況: −−−
登録日: 2013/1/9
居住地: 大阪
投稿: 1819
Re: 1種類の商品しかカートに入れられないようにする
SC_CartSession_Exに

    public function addProduct($product_class_id, $quantity)
    {
        $objProduct = new SC_Product_Ex();
        $arrProduct = $objProduct->getProductsClass($product_class_id);
        $productTypeId = $arrProduct['product_type_id'];
        $find = false;
        $max = $this->getMax($productTypeId);

        for ($i = 0; $i <= $max; $i++) {
            if ($this->cartSession[$productTypeId][$i]['id'] == $product_class_id) {
                $val = $this->cartSession[$productTypeId][$i]['quantity'] + $quantity;
                if (strlen($val) <= INT_LEN) {
                    $this->cartSession[$productTypeId][$i]['quantity'] += $quantity;
                }
                $find = true;
            }
        }
        if (!$find) {
            //追加↓
            $this->delAllProducts($productTypeId)
            //追加↑
            $this->cartSession[$productTypeId][$max+1]['id'] = $product_class_id;
            $this->cartSession[$productTypeId][$max+1]['quantity'] = $quantity;
            $this->cartSession[$productTypeId][$max+1]['cart_no'] = $this->getNextCartID($productTypeId);
        }
    }

これを追加でできるんじゃないですか?
カートに入っている商品以外を入れようとする前にいったんそのカートの商品を空にする処理を追加してます。
スレッド表示 | 新しいものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,712名です
総投稿数は109,949件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2313
5
umebius
2085
6
yuh
1819
7
h_tanaka
1638
8
red
1570
9
mcontact
1285
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
799
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.