0

I'm trying to create a basic shopping cart, having an issue with the product page allowing users to add more items to their cart then are in stock (I have code in place to prevent this on the view cart page, just not the view product page)

This is what I have so far;

for ($i = 0; $i < $numItem; $i++) {
extract($cartContent[$i]);
$subTotal += $price * $cartQuantity;
$cartLimiter[$itemNo => $cartQuantity];

Using an array so the position number becomes the item number and the cart quantity becomes the assigned value, however it doesn't seem to like it and throws out on the bottom line of code:

Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting ']'

Thanks

3 Answers 3

1

Change this:

$cartLimiter[$itemNo => $cartQuantity];

to:

$cartLimiter[$itemNo] = $cartQuantity;
Sign up to request clarification or add additional context in comments.

Comments

0
$cartLimiter[$itemNo] = $cartQuantity;

Comments

0

$cartLimiter[$itemNo] = $cartQuantity;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.