Skip to content

Commit

Permalink
Merge pull request #5581 from CongThuong/thuong
Browse files Browse the repository at this point in the history
use minQuantiy to increase or decrease quantity
  • Loading branch information
Lu Nguyen Nhat authored Jul 4, 2022
2 parents 6698aec + 6321376 commit 159fcc3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<input class="quantity" type="text" id="quantity{{ productId }}" name="quantity" size="1" value="{{ quantity }}"
onkeypress="return event.keyCode!=13">
<input type="button" class="myupbutton" value="+"
onClick="quantity{{ productId }}.value = (+quantity{{ productId }}.value+1);">
<input type="button" class="mydownbutton" value="-"
onClick="quantity{{ productId }}.value = (quantity{{ productId }}.value); var qty1 = quantity{{ productId }}.value; if( !isNaN( qty1 ) &amp;&amp; qty1 > 1 ) quantity{{ productId }}.value--;return false;"/>
<span class="quantity_sp01"><input type="button" class="myupbutton" value="+"
onClick="if({{ minQuantity }} > 0){quantity{{ productId }}.value = (+quantity{{ productId }}.value+{{ minQuantity }})}else quantity{{ productId }}.value = (+quantity{{ productId }}.value+1);"></span>
<span class="quantity_sp02"><input type="button" class="mydownbutton" value="-"
onClick="if({{ minQuantity }} > 0 &amp;&amp; quantity{{ productId }}.value >= {{ minQuantity }}){quantity{{ productId }}.value = parseInt(quantity{{ productId }}.value - {{ minQuantity}} ) }else if({{ minQuantity}} == 0) {quantity{{ productId }}.value = (quantity{{ productId }}.value); var qty1 = quantity{{ productId }}.value; if( !isNaN( qty1 ) &amp;&amp; qty1 > 1 ) quantity{{ productId }}.value--;return false;}"/></span>
7 changes: 4 additions & 3 deletions libraries/redshop/tags/sections/addtocart.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public function replace()
$this->replaceQuantity($productId, $stockId, $quantity, $template);
} elseif ($this->isTagExists('{addtocart_quantity_increase_decrease}')) {
$checkTag = true;
$this->replaceQuantityIncreaseDecrease($productId, $cartId, $itemId, $quantity, $template);
$this->replaceQuantityIncreaseDecrease($productId, $cartId, $itemId, $quantity,$minQuantity, $template);
} elseif ($this->isTagExists('{addtocart_quantity_selectbox}')) {
$checkTag = true;
$selectBoxValue = ($product->quantity_selectbox_value) ?
Expand Down Expand Up @@ -676,15 +676,16 @@ public function replaceQuantity($productId, $stockId, $quantity, &$template)
);
}

public function replaceQuantityIncreaseDecrease($productId, $cartId, $itemId, $quantity, &$template)
public function replaceQuantityIncreaseDecrease($productId, $cartId, $itemId, $quantity, $minQuantity ,&$template)
{
$quantityIncreaseDecrease = RedshopLayoutHelper::render(
'tags.addtocart.quantity_increase_decrease',
array(
'productId' => $productId,
'cartId' => $cartId,
'itemId' => $itemId,
'quantity' => $quantity
'quantity' => $quantity,
'minQuantity' => $minQuantity
),
'',
RedshopLayoutHelper::$layoutOption
Expand Down

0 comments on commit 159fcc3

Please sign in to comment.