subscribepro / subscribepro-magento2-ext

Subscribe Pro Magento 2 Integration Extension
MIT License
24 stars 22 forks source link

Cart price rule issue reported - `reorder_ordinal` #191

Closed garthbrantley closed 10 months ago

garthbrantley commented 1 year ago

PRs: #245

Ensure that Reorder Ordinal is not set on cart line items when orders created using the

Bug Report

There are two scenarios through which a reorder ordinal can (incorrectly) make its way into a quote / cart in Adobe Commerce. This allows for undesired application of cart price rules / discounts that are based on reorder ordinals in the conditions:

Reorder (from My Account > My Orders) of a recurring order Failed recurring order (if it gets far enough to create a quote) There is financial / revenue impact to both of these, while the first is obviously likely to be more prevalent.

To address this, a possible technical approach might be an observer for the sales_quote_save_before​ Adobe Commerce event, where the execute()​ function would loop through the items being added to the quote and strip out reorder_ordinal, subscription_id, and any other data which shouldn't persist into a new order.

eugene-shab commented 11 months ago

@garthbrantley If I understand correctly, the quote that is created during reordering should not contain reorder_ordinary.

Can you provide if are there specific steps to reproduce a quote with an established value of reorder_ordinary?

I have tested different variations of reorder creation, reorder_ordinary value appears only when creating an order from the platform with the quote value is_fulfilling = true and reorder_ordinary = value, in other cases (My account and admin panel) quotes are created with create_new_subscription_at_checkout = true and without reoder_ordinary

garthbrantley commented 11 months ago

@chrismshea Can you attempt to reproduce this and then document steps-to-reproduce?

chrismshea commented 11 months ago

Below Steps were done from Main at 4859774

Steps to reproduce

  1. On Magento 2 Frontend create a new subscription.
  2. From Subscribe Pro create a Recurring type reorder Image Image Image
  3. Verify the id of the order in Magento 2 Image
  4. View the ordinal sent in the sales_order_item table. Image
  5. From the Customer My Account > My Orders find the successful recurring order placed Image
  6. Continue with a One Time Order Image
  7. Note there is a subscription discount applied Image
  8. View the placed order and note the interval and subscription id from the original recurring order from SP Image
  9. View the record in the DB sales_order_item table, and see the reorder_ordinal used from the original recurring order from SP Image
  10. Same results occur if choosing regular deliver from reorder of original recurring order. Image

These issues do not occur if doing a reorder from the sp recurring order in the admin one time or regular.

  1. Create reorder from recurring order in admin Image
  2. No subscription created, and no reused ordinal or sub id Image
  3. Create a regular delivery order from recurring order Image
  4. Subscription created, and new sub id and no reorder_ordinal Image
eugene-shab commented 10 months ago

@garthbrantley Since during the reorder the data for the new quote is taken from the old one, I saved the default values for the subscription options. Now when the reorderer is triggered, item options will be reset

image