AntonLV 6 лет назад
Родитель
Сommit
9c05abd97f

+ 33 - 7
modules/base/payment/classes/BxBaseModPaymentCart.php

@@ -196,19 +196,45 @@ class BxBaseModPaymentCart extends BxDol
         return $iCount;
     }
 
-	protected function _parseByVendor($iUserId)
-    {
-        $sItems = $this->_oModule->_oDb->getCartItems($iUserId);
-        return $this->_reparseBy($this->_oModule->_oConfig->descriptorsM2A($sItems), 'vendor_id');
+    protected function _parseByVendor($iUserId)
+    {                            
+        $aCart = $this->_oModule->_oDb->getCartContent($iUserId);
+        if(empty($aCart['items']))
+            return array();
+
+        $aResult = $this->_reparseBy($this->_oModule->_oConfig->descriptorsM2A($aCart['items']), 'vendor_id');
+        if(empty($aCart['customs']))
+            return $aResult;
+
+        $aCartCustoms = unserialize($aCart['customs']);
+
+        foreach($aResult as $iVendor => $aItems)
+            foreach($aItems as $iIndex => $aItem)
+                $aResult[$iVendor][$iIndex]['custom'] = $this->_oModule->_oConfig->pullCustom($aItem, $aCartCustoms);
+
+        return $aResult;
     }
 
     protected function _parseByModule($iUserId)
     {
-        $sItems = $this->_oModule->_oDb->getCartItems($iUserId);
-        return $this->_reparseBy($this->_oModule->_oConfig->descriptorsM2A($sItems), 'module_id');
+        $aCart = $this->_oModule->_oDb->getCartContent($iUserId);
+        if(empty($aCart['items']))
+            return array();
+
+        $aResult = $this->_reparseBy($this->_oModule->_oConfig->descriptorsM2A($aCart['items']), 'module_id');
+        if(empty($aCart['customs']))
+            return $aResult;
+
+        $aCartCustoms = unserialize($aCart['customs']);
+
+        foreach($aResult as $iModule => $aItems)
+            foreach($aItems as $iIndex => $aItem)
+                $aResult[$iModule][$iIndex]['custom'] = $this->_oModule->_oConfig->pullCustom($aItem, $aCartCustoms);
+
+        return $aResult;
     }
 
-	protected function _reparseBy($aItems, $sKey)
+    protected function _reparseBy($aItems, $sKey)
     {
         $aResult = array();
         foreach($aItems as $aItem)

+ 6 - 5
modules/boonex/payment/classes/BxPaymentCart.php

@@ -162,7 +162,7 @@ class BxPaymentCart extends BxBaseModPaymentCart
     	$iModuleId = $this->_oModule->_oConfig->getModuleId($mixedModuleId);
     	$iClientId = $this->_oModule->getProfileId();
 
-    	$mixedResult = $this->_oModule->checkData($iClientId, $iSellerId, $iModuleId, $iItemId, $iItemCount);
+    	$mixedResult = $this->_oModule->checkData($iClientId, $iSellerId, $iModuleId, $iItemId, $iItemCount, $aCustom);
     	if($mixedResult !== true)
     		return $mixedResult;
 
@@ -176,10 +176,11 @@ class BxPaymentCart extends BxBaseModPaymentCart
         $sCiDsc = $this->_oModule->_oConfig->descriptorA2S(array($iSellerId, $iModuleId, $iItemId));
         if(strpos($sCartItems, $sCiDsc) !== false)
             $sCartItems = preg_replace_callback(
-            	"/" . $this->_oModule->_oConfig->descriptorA2S(array($iSellerId, $iModuleId, $iItemId, '([0-9])+')) . "/", 
-            	create_function('$aMatches', 'return ' . $this->_oModule->_oConfig->descriptorA2S(array("'" . $iSellerId, $iModuleId, $iItemId, "' . (\$aMatches[1] + " . $iItemCount . ")")) . ';'),
+                "/" . $this->_oModule->_oConfig->descriptorA2S(array($iSellerId, $iModuleId, $iItemId, '([0-9])+')) . "/", function($aMatches) use($iSellerId, $iModuleId, $iItemId, $iItemCount) {
+                    return $this->_oModule->_oConfig->descriptorA2S(array($iSellerId, $iModuleId, $iItemId, $aMatches[1] + $iItemCount));
+                },
             	$sCartItems
-			);
+            );
         else {
             $sCartItem = $this->_oModule->_oConfig->descriptorA2S(array($iSellerId, $iModuleId, $iItemId, $iItemCount));
             $sCartItems = empty($sCartItems) ? $sCartItem : $sCartItems . $this->_oModule->_oConfig->getDivider('DIVIDER_DESCRIPTORS') . $sCartItem;
@@ -298,7 +299,7 @@ class BxPaymentCart extends BxBaseModPaymentCart
         $fItemsPrice = 0;
         $aItemsInfo = array();
         foreach($aItems as $aItem) {
-            $aItemInfo = $this->_oModule->callGetCartItem((int)$aItem['module_id'], array($aItem['item_id']));
+            $aItemInfo = $this->_oModule->callGetCartItem((int)$aItem['module_id'], array($aItem['item_id'], isset($aItem['custom']) ? $aItem['custom'] : array()));
             if(empty($aItemInfo) || !is_array($aItemInfo)) {
                 if($bTypeSingle) {
                     $sCartItems = $this->_oModule->_oDb->getCartItems($iClientId);

+ 3 - 3
modules/boonex/payment/classes/BxPaymentModule.php

@@ -758,7 +758,7 @@ class BxPaymentModule extends BxBaseModPaymentModule
     {
         $iUserId = (int)$this->getProfileId();
 
-        $aItemInfo = $this->callGetCartItem((int)$aItem['module_id'], array($aItem['item_id']));
+        $aItemInfo = $this->callGetCartItem((int)$aItem['module_id'], array($aItem['item_id'], isset($aItem['custom']) ? $aItem['custom'] : array()));
         if(empty($aItemInfo))
             return false;
 
@@ -806,7 +806,7 @@ class BxPaymentModule extends BxBaseModPaymentModule
         return $aCheckResult[CHECK_ACTION_MESSAGE];
     }
 
-    public function checkData($iClientId, $iSellerId, $iModuleId, $iItemId, $iItemCount)
+    public function checkData($iClientId, $iSellerId, $iModuleId, $iItemId, $iItemCount, $aCustom = array())
     {
     	$CNF = &$this->_oConfig->CNF;
 
@@ -819,7 +819,7 @@ class BxPaymentModule extends BxBaseModPaymentModule
             return array('code' => 2, 'eval' => 'window.open("' . $sLoginUrl . '", "_self");');
         }
 
-        $mixedResult = $this->isAllowedPurchase(array('module_id' => $iModuleId, 'item_id' => $iItemId));
+        $mixedResult = $this->isAllowedPurchase(array('module_id' => $iModuleId, 'item_id' => $iItemId, 'custom' => $aCustom));
         if($mixedResult !== true) {
             if(is_string($mixedResult) && !empty($mixedResult))
                 return array('code' => 2, 'message' => $mixedResult);