Skip to content

Several bug fix on cart related with products stock#501

Merged
kpodemski merged 3 commits intoPrestaShop:developfrom
GytisZum:ticket_488/several_bugs_fix_in_cart
Jun 23, 2023
Merged

Several bug fix on cart related with products stock#501
kpodemski merged 3 commits intoPrestaShop:developfrom
GytisZum:ticket_488/several_bugs_fix_in_cart

Conversation

@GytisZum
Copy link
Contributor

@GytisZum GytisZum commented Jun 6, 2023

Questions Answers
Description? There is several bug fixes. First of them is "Proceed to checkout" button disabling in cart page if order is not available and product has not enough quantity. Second is about the toast color which changed from yellow (warning) to red (danger). Third. The product quantity in input and in cart is set to max if customer has more then it exist in stock. This fix will not allow customer to add more products into cart if quantity is more then in stock and allow out-of-stock products is disabled is and both input and cart is falling back into previous value. As well this fix contains console error fix.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes #488
Sponsor company PrestaShop Corp.

How to test:

Button Disabled:

Steps:

  1. Go to back office and set "Mug Today is a good day" quantity to 1 and allow out-of-stock product to order.
  2. Go to front office and add more then 1 "Mug Today is a good day"
  3. Go back to back office and deny out-of-stock product to order.
  4. Go back to front office refresh the page and see the disabled button.
    image

Toast Color:

  1. Go to back office and set "Mug Today is a good day" quantity to 1 and deny out-of-stock product to order.
  2. Go to front office and add more then 1 "Mug Today is a good day"
  3. Go to cart and increase quantity of that product.
  4. The toast color should be red.
    image

Product quantity fix:

  1. Go to back office and set "Mug Today is a good day" quantity to 1 and deny out-of-stock product to order.
  2. Go to front office and add more then 1 "Mug Today is a good day"
  3. Go to cart and increase quantity of that product.
  4. Then amount in cart is exceeded with current stock amount you should see the toast and input value which will change back to previous.

Bonus fix:

Console error:
image

This error is occurred due to loading element which does not exist yet, but it's trying to initiate it on checkout pages. This error related with carrier extra content on checkout.
To test it need to check if carrier extra content works as previously.

Environment:

Hummingbird version: develop
PrestaShop version 8.1.0

Comment on lines +148 to +155
if (productData) {
if (productData.availability === 'unavailable'
&& productData.allow_oosp === 0
&& Number(productData.quantity_wanted) > Number(productData.stock_quantity)) {
const diff = Number(productData.stock_quantity) - Number(productData.quantity_wanted);
await sendUpdateCartRequest(productData.update_quantity_url as string, diff);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (productData) {
if (productData.availability === 'unavailable'
&& productData.allow_oosp === 0
&& Number(productData.quantity_wanted) > Number(productData.stock_quantity)) {
const diff = Number(productData.stock_quantity) - Number(productData.quantity_wanted);
await sendUpdateCartRequest(productData.update_quantity_url as string, diff);
}
}
if (productData
&& productData.availability === 'unavailable'
&& productData.allow_oosp === 0
&& Number(productData.quantity_wanted) > Number(productData.stock_quantity)) {
const diff = Number(productData.stock_quantity) - Number(productData.quantity_wanted);
await sendUpdateCartRequest(productData.update_quantity_url as string, diff);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion, your solution looks more readable 🔥

Copy link
Contributor

@ga-devfront ga-devfront left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all it's good for me, thank you for your contribution !

Copy link

@sallemiines sallemiines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @GytisZum
Thanx for this PR !

I tried to check this PR , and here is some feedback :

  • Proceed to checkout" button is not disable in the cart page if order is not available and product has not enough quantityif order is not available and product has not enough quantity ❌

  • Toast color is changed to red 🆗 but the order quantity for this product not exist ❌
    You can check the attached screen recorder

Product.1789.mp4
  • The amount in cart is exceeded with current stock amount you should see the toast and input value which will change back to previous. ❌

You can check the attached screen recorder

Cart.mp4

Please check & feedback !
Thank y !

Copy link

@sallemiines sallemiines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @GytisZum
Thanx for this PR !

I tried to check this PR , and here is some feedback :

  • Proceed to checkout" button is not disable in the cart page if order is not available and product has not enough quantityif order is not available and product has not enough quantity ❌

  • Toast color is changed to red 🆗 but the order quantity for this product not exist ❌
    You can check the attached screen recorder

Product.1789.mp4
  • The amount in cart is exceeded with current stock amount you should see the toast and input value which will change back to previous. ❌

You can check the attached screen recorder

Cart.mp4

Please check & feedback !
Thank y !

@GytisZum
Copy link
Contributor Author

GytisZum commented Jun 19, 2023

Hello,

thanks you for testing the fixes. However I see that you are using PrestaShop version 1.7.8.9.
We already know that older PrestaShop version works differently and we were informed that we need to be compatible only from PrestaShop 8.1.0

Please can you check on PrestaShop 8.1.0 ??
Thank you :)

@sallemiines
Copy link

  1. Mug Today is a good day

Thnx for your feedback !

I re-test the PR on PS 810 as you mentioned before

  • Proceed to checkout" button is not disable in the cart page if order is not available and product has not enough quantityif order is not available and product has not enough quantity ✔️

  • Toast color is changed to red and the order quantity for this product ✔️ but it appears and disappear quickly in the wrong placement ❌

You can check the attached screen recorder

Mug.Today.is.a.good.day.mp4

Waiting for yr feedback !

Thank you

@sallemiines sallemiines self-assigned this Jun 19, 2023
@GytisZum
Copy link
Contributor Author

  1. Mug Today is a good day

Thnx for your feedback !

I re-test the PR on PS 810 as you mentioned before

* **Proceed to checkout**" button is not disable in the cart page if order is not available and product has not enough quantityif order is not available and product has not enough quantity heavy_check_mark

* Toast color is changed to red and  the order quantity for this product  heavy_check_mark  but it appears and disappear quickly in the wrong placement x

You can check the attached screen recorder
Mug.Today.is.a.good.day.mp4

Waiting for yr feedback !

Thank you

Hello again,

Thank You for Your Feedback !!
I did several tests with different PrestaShop versions and I was able to recreate your issue with PrestaShop 8.1.0-beta.1

After comparison I found that real candidate version has changes in cart page which affects the behavior of the error messages.

I did some communication with the core team and got answer that tests must be done on stable version which does not exist at the moment, but closest one is PrestaShop version 8.1.0-rc.1.

Sorry I was not precise enough, but maybe you can test it on more stable version ?? :)

Waiting for the feedback
Thank you

@kpodemski
Copy link
Contributor

@sallemiines you can use the same build that QA tests for the final 8.1 release

Copy link

@aniszr aniszr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @GytisZum

Thanks for your PR, I tested it with 8.1.0 build 2 & Develop .

  • Proceed to checkout" button is not disable in the cart page if order is not available and product has not enough quantityif order is not available and product has not enough quantity ✔️

  • Toast color is changed to red and the order quantity for this product ✔️

  • Amount in cart is exceeded with current stock amount you should see the toast and input value which will change back to previous. ✔️

LGTM, QA ✔️

See attached screenshots:
image
image

Mug.Today.is.a.good.day.mp4

Thanks!

@Progi1984
Copy link
Member

Ping @Hlavtox for merge 😉

@kpodemski kpodemski merged commit 1049d1e into PrestaShop:develop Jun 23, 2023
@kpodemski
Copy link
Contributor

thanks @GytisZum

@tajriba
Copy link

tajriba commented Jul 5, 2023

@kpodemski hi, i want this also fixed for 8.0.X .
It works on the checkout/cart pages these changes.
But on the product page, it still add's the product to the cart. Any idea ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[FO] CART- When your add more items to cart than is in stock there are few issues

9 participants