예제 #1
0
 /**
  * カート内の商品の妥当性をチェックする.
  *
  * エラーが発生した場合は, 商品をカート内から削除又は数量を調整し,
  * エラーメッセージを返す.
  *
  * 1. 商品種別に関連づけられた配送業者の存在チェック
  * 2. 削除/非表示商品のチェック
  * 3. 販売制限数のチェック
  * 4. 在庫数チェック
  *
  * @param string $productTypeId 商品種別ID
  * @return string エラーが発生した場合はエラーメッセージ
  */
 function checkProducts($productTypeId)
 {
     $objProduct = new SC_Product_Ex();
     $tpl_message = '';
     // カート内の情報を取得
     $arrItems = $this->getCartList($productTypeId);
     foreach ($arrItems as &$arrItem) {
         $product =& $arrItem['productsClass'];
         /*
          * 表示/非表示商品のチェック
          */
         if (SC_Utils_Ex::isBlank($product) || $product['status'] != 1) {
             $this->delProduct($arrItem['cart_no'], $productTypeId);
             $tpl_message .= t('c_* A product in your cart is no longer being sold at this time. The item was deleted from your cart._01');
         } else {
             /*
              * 配送業者のチェック
              */
             $arrDeliv = SC_Helper_Purchase_Ex::getDeliv($productTypeId);
             if (SC_Utils_Ex::isBlank($arrDeliv)) {
                 $tpl_message .= t('c_* Delivery preparations are not ready  for T_ARG1. Please access the inquiry page for more details._01', array('T_ARG1' => $product['name']));
                 $this->delProduct($arrItem['cart_no'], $productTypeId);
             }
             /*
              * 販売制限数, 在庫数のチェック
              */
             $limit = $objProduct->getBuyLimit($product);
             if (!is_null($limit) && $arrItem['quantity'] > $limit) {
                 if ($limit > 0) {
                     $this->setProductValue($arrItem['id'], 'quantity', $limit, $productTypeId);
                     $total_inctax = SC_Helper_DB_Ex::sfCalcIncTax($arrItem['price']) * $limit;
                     $this->setProductValue($arrItem['id'], 'total_inctax', $total_inctax, $productTypeId);
                     $tpl_message .= t('c_* There is a sale restriction (or inventory shortage) for T_ARG1. It is not possible to purchase a quantity that exceeds T_ARG2 in a single purchase._01', array('T_ARG1' => $product['name'], 'T_ARG2' => $limit));
                 } else {
                     $this->delProduct($arrItem['cart_no'], $productTypeId);
                     $tpl_message .= t('c_* T_ARG1 is sold out._01', array('T_ARG1' => $product['name']));
                     continue;
                 }
             }
         }
     }
     return $tpl_message;
 }
 /**
  * カート内の商品の妥当性をチェックする.
  *
  * エラーが発生した場合は, 商品をカート内から削除又は数量を調整し,
  * エラーメッセージを返す.
  *
  * 1. 商品種別に関連づけられた配送業者の存在チェック
  * 2. 削除/非表示商品のチェック
  * 3. 販売制限数のチェック
  * 4. 在庫数チェック
  *
  * @param  string $productTypeId 商品種別ID
  * @return string エラーが発生した場合はエラーメッセージ
  */
 public function checkProducts($productTypeId)
 {
     $objProduct = new SC_Product_Ex();
     $objDelivery = new SC_Helper_Delivery_Ex();
     $arrDeliv = $objDelivery->getList($productTypeId);
     $tpl_message = '';
     // カート内の情報を取得
     $arrItems = $this->getCartList($productTypeId);
     foreach ($arrItems as &$arrItem) {
         $product =& $arrItem['productsClass'];
         /*
          * 表示/非表示商品のチェック
          */
         if (SC_Utils_Ex::isBlank($product) || $product['status'] != 1) {
             $this->delProduct($arrItem['cart_no'], $productTypeId);
             $tpl_message .= "※ 現時点で販売していない商品が含まれておりました。該当商品をカートから削除しました。\n";
         } else {
             /*
              * 配送業者のチェック
              */
             if (SC_Utils_Ex::isBlank($arrDeliv)) {
                 $tpl_message .= '※「' . $product['name'] . '」はまだ配送の準備ができておりません。';
                 $tpl_message .= '恐れ入りますがお問い合わせページよりお問い合わせください。' . "\n";
                 $this->delProduct($arrItem['cart_no'], $productTypeId);
             }
             /*
              * 販売制限数, 在庫数のチェック
              */
             $limit = $objProduct->getBuyLimit($product);
             if (!is_null($limit) && $arrItem['quantity'] > $limit) {
                 if ($limit > 0) {
                     $this->setProductValue($arrItem['id'], 'quantity', $limit, $productTypeId);
                     $total_inctax = $limit * SC_Helper_TaxRule_Ex::sfCalcIncTax($arrItem['price'], $product['product_id'], $arrItem['id'][0]);
                     $this->setProductValue($arrItem['id'], 'total_inctax', $total_inctax, $productTypeId);
                     $tpl_message .= '※「' . $product['name'] . '」は販売制限(または在庫が不足)しております。';
                     $tpl_message .= "一度に数量{$limit}を超える購入はできません。\n";
                 } else {
                     $this->delProduct($arrItem['cart_no'], $productTypeId);
                     $tpl_message .= '※「' . $product['name'] . "」は売り切れました。\n";
                     continue;
                 }
             }
         }
     }
     return $tpl_message;
 }
예제 #3
0
 /**
  * カート内の商品の妥当性をチェックする.
  *
  * エラーが発生した場合は, 商品をカート内から削除又は数量を調整し,
  * エラーメッセージを返す.
  *
  * 1. 商品種別に関連づけられた配送業者の存在チェック
  * 2. 削除/非表示商品のチェック
  * 3. 商品購入制限数のチェック
  * 4. 在庫数チェック
  *
  * @param string $key 商品種別ID
  * @return string エラーが発生した場合はエラーメッセージ
  */
 function checkProducts($productTypeId)
 {
     $objProduct = new SC_Product_Ex();
     $tpl_message = "";
     // カート内の情報を取得
     $items = $this->getCartList($productTypeId);
     foreach (array_keys($items) as $key) {
         $item =& $items[$key];
         $product =& $item['productsClass'];
         /*
          * 表示/非表示商品のチェック
          */
         if (SC_Utils_Ex::isBlank($product)) {
             $this->delProduct($item['cart_no'], $productTypeId);
             $tpl_message .= "※ 現時点で販売していない商品が含まれておりました。該当商品をカートから削除しました。\n";
         } else {
             /*
              * 配送業者のチェック
              */
             $arrDeliv = SC_Helper_Purchase_Ex::getDeliv($productTypeId);
             if (SC_Utils_Ex::isBlank($arrDeliv)) {
                 $tpl_message .= "※「" . $product['name'] . "」はまだ配送の準備ができておりません。恐れ入りますがお問い合わせページよりお問い合わせください。\n";
                 $this->delProduct($item['cart_no'], $productTypeId);
             }
             /*
              * 商品購入制限数, 在庫数のチェック
              */
             $limit = $objProduct->getBuyLimit($product);
             if (!is_null($limit) && $item['quantity'] > $limit) {
                 if ($limit > 0) {
                     $this->setProductValue($item['id'], 'quantity', $limit, $productTypeId);
                     $this->setProductValue($item['id'], 'total_inctax', SC_Helper_DB_Ex::sfCalcIncTax($item['price']) * $limit, $productTypeId);
                     $tpl_message .= "※「" . $product['name'] . "」は販売制限(または在庫が不足)しております。一度に数量{$limit}以上の購入はできません。\n";
                 } else {
                     $this->delProduct($item['cart_no'], $productTypeId);
                     $tpl_message .= "※「" . $product['name'] . "」は売り切れました。\n";
                     continue;
                 }
             }
         }
     }
     return $tpl_message;
 }