[-] BO : fixed bug #PSCFV-1296 - Can't add a product in order (BO)

// Fix backward compatibility issue with updateQty method

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15152 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
aFolletete
2012-05-10 09:29:46 +00:00
parent 8cede91978
commit 47cfd2b9f9
6 changed files with 15 additions and 15 deletions

View File

@@ -69,16 +69,16 @@
<input type="hidden" name="totalQty" id="totalQty" value="{$product['product_quantity']}" />
<input type="hidden" name="productName" id="productName" value="{$product['product_name']}" />
{if ((!$order->hasBeenDelivered() OR Configuration::get('PS_ORDER_RETURN')) AND (int)($product['product_quantity_return']) < (int)($product['product_quantity']))}
<input type="checkbox" name="id_order_detail[{$k}]" id="id_order_detail[{$k}]" value="{$product['id_order_detail']}" onchange="setCancelQuantity(this, {$product['id_order_detail']}, {$product['product_quantity_in_stock'] - $product['customizationQuantityTotal'] - $product['product_quantity_reinjected']})" {if ($product['product_quantity_return'] + $product['product_quantity_refunded'] >= $product['product_quantity'])}disabled="disabled" {/if}/>
<input type="checkbox" name="id_order_detail[{$product['id_order_detail']}]" id="id_order_detail[{$product['id_order_detail']}]" value="{$product['id_order_detail']}" onchange="setCancelQuantity(this, {$product['id_order_detail']}, {$product['product_quantity_in_stock'] - $product['customizationQuantityTotal'] - $product['product_quantity_reinjected']})" {if ($product['product_quantity_return'] + $product['product_quantity_refunded'] >= $product['product_quantity'])}disabled="disabled" {/if}/>
{else}
--
{/if}
</td>
<td class="cancelQuantity standard_refund_fields current-edit" style="display:none">
{if ($product['product_quantity_return'] + $product['product_quantity_refunded'] >= $product['product_quantity'])}
<input type="hidden" name="cancelQuantity[{$k}]" value="0" />
<input type="hidden" name="cancelQuantity[{$product['id_order_detail']}]" value="0" />
{elseif (!$order->hasBeenDelivered() OR Configuration::get('PS_ORDER_RETURN'))}
<input type="text" id="cancelQuantity_{$product['id_order_detail']}" name="cancelQuantity[{$k}]" size="2" onclick="selectCheckbox(this);" value="" />
<input type="text" id="cancelQuantity_{$product['id_order_detail']}" name="cancelQuantity[{$product['id_order_detail']}]" size="2" onclick="selectCheckbox(this);" value="" />
{/if}
{if $product['customizationQuantityTotal']}
@@ -96,8 +96,8 @@
{/if}
</td>
<td class="partial_refund_fields current-edit" style="text-align:left;display:none">
<div style="width:40%;margin-top:5px;float:left">{l s='Quantity:'}</div> <div style="width:60%;margin-top:2px;float:left"><input type="text" size="3" name="partialRefundProductQuantity[{$k}]" value="0" /> 0/{$productQuantity-$product['product_quantity_refunded']}</div>
<div style="width:40%;margin-top:5px;float:left">{l s='Amount:'}</div> <div style="width:60%;margin-top:2px;float:left"><input type="text" size="3" name="partialRefundProduct[{$k}]" /> &euro;</div>
<div style="width:40%;margin-top:5px;float:left">{l s='Quantity:'}</div> <div style="width:60%;margin-top:2px;float:left"><input type="text" size="3" name="partialRefundProductQuantity[{{$product['id_order_detail']}}]" value="0" /> 0/{$productQuantity-$product['product_quantity_refunded']}</div>
<div style="width:40%;margin-top:5px;float:left">{l s='Amount:'}</div> <div style="width:60%;margin-top:2px;float:left"><input type="text" size="3" name="partialRefundProduct[{$product['id_order_detail']}]" /> &euro;</div>
</td>
{if ($can_edit && !$order->hasBeenDelivered())}
<td class="product_invoice" colspan="2" style="display: none;text-align:center;">

View File

@@ -759,7 +759,7 @@ class CartCore extends ObjectModel
Cache::clean('Cart::getCartRules'.$this->id.'-'.CartRule::FILTER_ACTION_GIFT);
if ((int)$cartRule->gift_product)
$this->updateQty(1, $cartRule->gift_product, $cartRule->gift_product_attribute, false, 0, 'up', null, false);
$this->updateQty(1, $cartRule->gift_product, $cartRule->gift_product_attribute, false, 'up', 0, null, false);
return true;
}
@@ -796,7 +796,7 @@ class CartCore extends ObjectModel
* @param string $operator Indicate if quantity must be increased or decreased
*/
public function updateQty($quantity, $id_product, $id_product_attribute = null, $id_customization = false,
$id_address_delivery = 0, $operator = 'up', Shop $shop = null, $auto_add_cart_rule = true)
$operator = 'up', $id_address_delivery = 0, Shop $shop = null, $auto_add_cart_rule = true)
{
if (!$shop)
$shop = Context::getContext()->shop;
@@ -833,7 +833,7 @@ class CartCore extends ObjectModel
if ((int)$quantity <= 0)
return $this->deleteProduct($id_product, $id_product_attribute, (int)$id_customization);
else if (!$product->available_for_order || Configuration::get('PS_CATALOG_MODE'))
elseif (!$product->available_for_order || Configuration::get('PS_CATALOG_MODE'))
return false;
else
{
@@ -1088,7 +1088,7 @@ class CartCore extends ObjectModel
$cart_rule = new CartRule($id_cart_rule, Configuration::get('PS_LANG_DEFAULT'));
if ((int)$cart_rule->gift_product)
$this->updateQty(1, $cart_rule->gift_product, $cart_rule->gift_product_attribute, null, null, 'down', null, false);
$this->updateQty(1, $cart_rule->gift_product, $cart_rule->gift_product_attribute, null, 'down', 0, null, false);
return $result;
}
@@ -2853,8 +2853,8 @@ class CartCore extends ObjectModel
(int)$product['id_product'],
(int)$product['id_product_attribute'],
null,
(int)$product['id_address_delivery'],
'up',
(int)$product['id_address_delivery'],
new Shop($cart->id_shop)
);

View File

@@ -349,7 +349,7 @@ class OrderCore extends ObjectModel
$productPrice = number_format($quantity * $price, 2, '.', '');
/* Update cart */
$cart = new Cart($this->id_cart);
$cart->updateQty($quantity, $orderDetail->product_id, $orderDetail->product_attribute_id, false, 0, 'down'); // customization are deleted in deleteCustomization
$cart->updateQty($quantity, $orderDetail->product_id, $orderDetail->product_attribute_id, false, 'down'); // customization are deleted in deleteCustomization
$cart->update();
/* Update order */

View File

@@ -338,7 +338,7 @@ class AdminCartsControllerCore extends AdminController
else
$operator = 'up';
if (!($qty_upd = $this->context->cart->updateQty($qty, $id_product, (int)$id_product_attribute, (int)$id_customization, 0, $operator)))
if (!($qty_upd = $this->context->cart->updateQty($qty, $id_product, (int)$id_product_attribute, (int)$id_customization, $operator)))
$errors[] = Tools::displayError('You already have the maximum quantity available for this product.');
}

View File

@@ -1474,8 +1474,7 @@ class AdminOrdersControllerCore extends AdminController
}
// Add product to cart
$cart->updateQty($product_informations['product_quantity'], $product->id, isset($combination) ? $combination->id : null, false, 'up', new Shop($cart->id_shop));
$cart->updateQty($product_informations['product_quantity'], $product->id, isset($combination) ? $combination->id : null, false, 0, 'up', new Shop($cart->id_shop));
// If order is valid, we can create a new invoice or edit an existing invoice
if ($order->hasInvoice())
{
@@ -1587,6 +1586,7 @@ class AdminOrdersControllerCore extends AdminController
$specific_price->delete();
$products = $this->getProducts($order);
// Get the last product
$product = $products[max(array_keys($products))];

View File

@@ -226,7 +226,7 @@ class CartControllerCore extends FrontController
if (!$this->errors)
{
$cart_rules = $this->context->cart->getCartRules();
$updateQuantity = $this->context->cart->updateQty($this->qty, $this->id_product, $this->id_product_attribute, $this->customization_id, $this->id_address_delivery, Tools::getValue('op', 'up'));
$updateQuantity = $this->context->cart->updateQty($this->qty, $this->id_product, $this->id_product_attribute, $this->customization_id, Tools::getValue('op', 'up'), $this->id_address_delivery);
if ($updateQuantity < 0)
{
// If product has attribute, minimal quantity is set with minimal quantity of attribute