本文整理汇总了PHP中SC_FormParam::getSwapArray方法的典型用法代码示例。如果您正苦于以下问题:PHP SC_FormParam::getSwapArray方法的具体用法?PHP SC_FormParam::getSwapArray怎么用?PHP SC_FormParam::getSwapArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SC_FormParam
的用法示例。
在下文中一共展示了SC_FormParam::getSwapArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doRegister
/**
* DB更新処理
*
* @param integer $order_id 受注ID
* @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
* @param string $message 通知メッセージ
* @param array $arrValuesBefore 更新前の受注情報
* @return integer $order_id 受注ID
*
* エラー発生時は負数を返す。
*/
function doRegister($order_id, &$objPurchase, &$objFormParam, &$message, &$arrValuesBefore)
{
$objQuery =& SC_Query_Ex::getSingletonInstance();
$arrValues = $objFormParam->getDbArray();
$where = 'order_id = ?';
$objQuery->begin();
// 支払い方法が変更されたら、支払い方法名称も更新
if ($arrValues['payment_id'] != $arrValuesBefore['payment_id']) {
$arrValues['payment_method'] = $this->arrPayment[$arrValues['payment_id']];
$arrValuesBefore['payment_id'] = NULL;
}
// 受注テーブルの更新
$order_id = $objPurchase->registerOrder($order_id, $arrValues);
$arrDetail = $objFormParam->getSwapArray(array('product_id', 'product_class_id', 'product_code', 'product_name', 'price', 'quantity', 'point_rate', 'classcategory_name1', 'classcategory_name2'));
// 変更しようとしている商品情報とDBに登録してある商品情報を比較することで、更新すべき数量を計算
$max = count($arrDetail);
$k = 0;
$arrStockData = array();
for ($i = 0; $i < $max; $i++) {
if (!empty($arrDetail[$i]['product_id'])) {
$arrPreDetail = $objQuery->select('*', 'dtb_order_detail', 'order_id = ? AND product_class_id = ?', array($order_id, $arrDetail[$i]['product_class_id']));
if (!empty($arrPreDetail) && $arrPreDetail[0]['quantity'] != $arrDetail[$i]['quantity']) {
// 数量が変更された商品
$arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id'];
$arrStockData[$k]['quantity'] = $arrPreDetail[0]['quantity'] - $arrDetail[$i]['quantity'];
++$k;
} elseif (empty($arrPreDetail)) {
// 新しく追加された商品 もしくは 違う商品に変更された商品
$arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id'];
$arrStockData[$k]['quantity'] = -$arrDetail[$i]['quantity'];
++$k;
}
$objQuery->delete('dtb_order_detail', 'order_id = ? AND product_class_id = ?', array($order_id, $arrDetail[$i]['product_class_id']));
}
}
// 上記の新しい商品のループでDELETEされなかった商品は、注文より削除された商品
$arrPreDetail = $objQuery->select('*', 'dtb_order_detail', 'order_id = ?', array($order_id));
foreach ($arrPreDetail as $key => $val) {
$arrStockData[$k]['product_class_id'] = $val['product_class_id'];
$arrStockData[$k]['quantity'] = $val['quantity'];
++$k;
}
// 受注詳細データの更新
$objPurchase->registerOrderDetail($order_id, $arrDetail);
// 在庫数調整
if (ORDER_DELIV != $arrValues['status'] && ORDER_CANCEL != $arrValues['status']) {
foreach ($arrStockData as $stock) {
$objQuery->update('dtb_products_class', array(), 'product_class_id = ?', array($stock['product_class_id']), array('stock' => 'stock + ?'), array($stock['quantity']));
}
}
$arrAllShipping = $objFormParam->getSwapArray($this->arrShippingKeys);
$arrAllShipmentItem = $objFormParam->getSwapArray($this->arrShipmentItemKeys);
$arrDelivTime = $objPurchase->getDelivTime($objFormParam->getValue('deliv_id'));
$arrShippingValues = array();
foreach ($arrAllShipping as $shipping_index => $arrShipping) {
$shipping_id = $arrShipping['shipping_id'];
$arrShippingValues[$shipping_index] = $arrShipping;
$arrShippingValues[$shipping_index]['shipping_date'] = SC_Utils_Ex::sfGetTimestamp($arrShipping['shipping_date_year'], $arrShipping['shipping_date_month'], $arrShipping['shipping_date_day']);
// 配送業者IDを取得
$arrShippingValues[$shipping_index]['deliv_id'] = $objFormParam->getValue('deliv_id');
// お届け時間名称を取得
$arrShippingValues[$shipping_index]['shipping_time'] = $arrDelivTime[$arrShipping['time_id']];
// 複数配送の場合は配送商品を登録
if (!SC_Utils_Ex::isBlank($arrAllShipmentItem)) {
$arrShipmentValues = array();
foreach ($arrAllShipmentItem[$shipping_index] as $key => $arrItem) {
$i = 0;
foreach ($arrItem as $item) {
$arrShipmentValues[$shipping_index][$i][str_replace('shipment_', '', $key)] = $item;
$i++;
}
}
$objPurchase->registerShipmentItem($order_id, $shipping_id, $arrShipmentValues[$shipping_index]);
}
}
$objPurchase->registerShipping($order_id, $arrShippingValues, false);
$objQuery->commit();
return $order_id;
}
示例2: saveMultipleShippings
/**
* 複数配送情報を一時保存する.
*
* 会員ログインしている場合は, その他のお届け先から住所情報を取得する.
*
* @param integer $uniqid 一時受注テーブルのユニークID
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
* @param SC_Customer $objCustomer SC_Customer インスタンス
* @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
* @return void
*/
public function saveMultipleShippings($uniqid, &$objFormParam, &$objCustomer, &$objPurchase, &$objAddress)
{
$arrParams = $objFormParam->getSwapArray();
foreach ($arrParams as $arrParam) {
$other_deliv_id = $arrParam['shipping'];
if ($objCustomer->isLoginSuccess(true)) {
if ($other_deliv_id != 0) {
$otherDeliv = $objAddress->getAddress($other_deliv_id, $objCustomer->getValue('customer_id'));
if (!$otherDeliv) {
SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, "入力値が不正です。<br />正しい値を入力してください。");
SC_Response_Ex::actionExit();
}
foreach ($otherDeliv as $key => $val) {
$arrValues[$other_deliv_id]['shipping_' . $key] = $val;
}
} else {
$objPurchase->copyFromCustomer($arrValues[0], $objCustomer, 'shipping');
}
} else {
$arrValues = $objPurchase->getShippingTemp();
}
$arrItemTemp[$other_deliv_id][$arrParam['product_class_id']] += $arrParam['quantity'];
}
$objPurchase->clearShipmentItemTemp();
foreach ($arrValues as $shipping_id => $arrVal) {
$objPurchase->saveShippingTemp($arrVal, $shipping_id);
}
foreach ($arrItemTemp as $other_deliv_id => $arrProductClassIds) {
foreach ($arrProductClassIds as $product_class_id => $quantity) {
if ($quantity == 0) {
continue;
}
$objPurchase->setShipmentItemTemp($other_deliv_id, $product_class_id, $quantity);
}
}
//不必要な配送先を削除
foreach ($_SESSION['shipping'] as $id => $arrShipping) {
if (!isset($arrShipping['shipment_item'])) {
$objPurchase->unsetOneShippingTemp($id);
}
}
// $arrValues[0] には, 購入者の情報が格納されている
$objPurchase->saveOrderTemp($uniqid, $arrValues[0], $objCustomer);
}
示例3: setProductsQuantity
/**
* 商品側の総量計算&セット
*
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
* @return void
*/
public function setProductsQuantity(&$objFormParam)
{
$arrShipmentsItems = $objFormParam->getSwapArray(array('shipment_product_class_id', 'shipment_quantity'));
// 配送先が存在する時のみ、商品個数の再設定を行います
if (!SC_Utils_Ex::isBlank($arrShipmentsItems)) {
$arrUpdateQuantity = array();
foreach ($arrShipmentsItems as $arritems) {
foreach ($arritems['shipment_product_class_id'] as $relation_index => $shipment_product_class_id) {
$arrUpdateQuantity[$shipment_product_class_id] += $arritems['shipment_quantity'][$relation_index];
}
}
$arrProductsClass = $objFormParam->getValue('product_class_id');
$arrQuantity = array();
foreach ($arrProductsClass as $relation_key => $product_class_id) {
$arrQuantity[$relation_key] = isset($arrUpdateQuantity[$product_class_id]) ? $arrUpdateQuantity[$product_class_id] : 0;
}
$objFormParam->setParam(array('quantity' => $arrQuantity));
}
}
示例4: saveMultipleShippings
/**
* 複数配送情報を一時保存する.
*
* 会員ログインしている場合は, その他のお届け先から住所情報を取得する.
*
* @param integer $uniqid 一時受注テーブルのユニークID
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
* @param SC_Customer $objCustomer SC_Customer インスタンス
* @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
* @param SC_CartSession $objCartSess SC_CartSession インスタンス
* @return void
*/
function saveMultipleShippings($uniqid, &$objFormParam, &$objCustomer, &$objPurchase, &$objCartSess, &$objAddress)
{
$arrParams = $objFormParam->getSwapArray();
foreach ($arrParams as $arrParam) {
$other_deliv_id = $arrParam['shipping'];
if ($objCustomer->isLoginSuccess(true)) {
if ($other_deliv_id != 0) {
$otherDeliv = $objAddress->getAddress($other_deliv_id);
foreach ($otherDeliv as $key => $val) {
$arrValues[$other_deliv_id]['shipping_' . $key] = $val;
}
} else {
$objPurchase->copyFromCustomer($arrValues[0], $objCustomer, 'shipping');
}
} else {
$arrValues = $objPurchase->getShippingTemp();
}
$arrItemTemp[$other_deliv_id][$arrParam['product_class_id']] += $arrParam['quantity'];
}
$objPurchase->clearShipmentItemTemp();
foreach ($arrValues as $shipping_id => $arrVal) {
$objPurchase->saveShippingTemp($arrVal, $shipping_id);
}
foreach ($arrItemTemp as $other_deliv_id => $arrProductClassIds) {
foreach ($arrProductClassIds as $product_class_id => $quantity) {
if ($quantity == 0) {
continue;
}
$objPurchase->setShipmentItemTemp($other_deliv_id, $product_class_id, $quantity);
}
}
//不必要な配送先を削除
foreach ($_SESSION['shipping'] as $id => $arrShipping) {
if (!isset($arrShipping['shipment_item'])) {
$objPurchase->unsetOneShippingTemp($id);
}
}
// $arrValues[0] には, 購入者の情報が格納されている
$objPurchase->saveOrderTemp($uniqid, $arrValues[0], $objCustomer);
}
示例5: saveMultipleShippings
/**
* 複数配送情報を一時保存する.
*
* 会員ログインしている場合は, その他のお届け先から住所情報を取得する.
*
* @param integer $uniqid 一時受注テーブルのユニークID
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
* @param SC_Customer $objCustomer SC_Customer インスタンス
* @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
* @param SC_CartSession $objCartSess SC_CartSession インスタンス
* @return void
*/
function saveMultipleShippings($uniqid, &$objFormParam, &$objCustomer, &$objPurchase, &$objCartSess)
{
$objQuery =& SC_Query_Ex::getSingletonInstance();
$arrParams = $objFormParam->getSwapArray();
foreach ($arrParams as $arrParam) {
$other_deliv_id = $arrParam['shipping'];
if ($objCustomer->isLoginSuccess(true)) {
if ($other_deliv_id != 0) {
$otherDeliv = $objQuery->select('*', 'dtb_other_deliv', 'other_deliv_id = ?', array($other_deliv_id));
foreach ($otherDeliv[0] as $key => $val) {
$arrValues[$other_deliv_id]['shipping_' . $key] = $val;
}
} else {
$objPurchase->copyFromCustomer($arrValues[0], $objCustomer, 'shipping');
}
} else {
$arrValues = $objPurchase->getShippingTemp();
}
$arrItemTemp[$other_deliv_id][$arrParam['product_class_id']] += $arrParam['quantity'];
}
$objPurchase->clearShipmentItemTemp();
foreach ($arrValues as $shipping_id => $arrVal) {
$objPurchase->saveShippingTemp($arrVal, $shipping_id);
}
foreach ($arrItemTemp as $other_deliv_id => $arrProductClassIds) {
foreach ($arrProductClassIds as $product_class_id => $quantity) {
if ($quantity == 0) {
continue;
}
$objPurchase->setShipmentItemTemp($other_deliv_id, $product_class_id, $quantity);
}
}
// $arrValues[0] には, 購入者の情報が格納されている
$objPurchase->saveOrderTemp($uniqid, $arrValues[0], $objCustomer);
}