Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
T
test-webshop
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Artem
test-webshop
Commits
efc191ea
Commit
efc191ea
authored
May 17, 2020
by
Artem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
include checking for 0 and e in update qty methods
parent
01994e26
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
Cart.php
app/Cart.php
+4
-2
cart.js
public/js/cart.js
+6
-0
No files found.
app/Cart.php
View file @
efc191ea
...
...
@@ -45,9 +45,11 @@ class Cart
public
function
updateQty
(
$product_id
,
$changed_qty
)
{
$changed_qty
=
abs
(
$changed_qty
);
if
(
array_key_exists
(
$product_id
,
$this
->
items
))
{
if
(
$changed_qty
<
=
0
)
{
$this
->
removeItem
(
$product_id
)
;
if
(
$changed_qty
==
=
0
)
{
$this
->
items
[
$product_id
][
'qty'
]
=
1
;
}
else
{
$this
->
items
[
$product_id
][
'qty'
]
=
$changed_qty
;
}
...
...
public/js/cart.js
View file @
efc191ea
...
...
@@ -91,6 +91,12 @@ class Cart {
function
bindedUpdateItemQty
(
event
)
{
if
(
!
event
.
target
.
classList
.
contains
(
'js-qty-input'
))
return
;
const
changedQty
=
event
.
target
.
value
;
if
(
!
changedQty
||
(
changedQty
.
indexOf
(
'e'
)
+
1
)
||
changedQty
===
'0'
)
{
event
.
target
.
value
=
event
.
target
.
defaultValue
;
return
;
}
const
actionUrl
=
this
.
updateItemUrl
;
const
productId
=
event
.
target
.
dataset
.
productId
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment