subscribepro / subscribepro-magento2-ext

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

#182 Order Callback | Interval value not stored in sales_order_item and not shown in order email. #236

Closed eugene-shab closed 9 months ago

eugene-shab commented 9 months ago

feat: Fix interval value for callback orders.

Refs: #182

eugene-shab commented 9 months ago

Platform

i add product to the order callback in this way. i've tried different order type also.

paltform_add_produc_to_callback

From the Magento side

Our code: Screenshot from 2023-11-30 17-14-35

Case, Fulfils order callback:

Request comes into this file Updater::update(). Originally (before fix) in update() we have a condition like:

        if (!$createNewSubscriptionAtCheckout) {
            $subscriptionInterval = null;
        }

in row 50 i see a $subscriptionOption = 'onetime_purchase' after that on row 57-58 clean up the variable$subscriptionInterval, this caused a problem for Fulfils order request. i think we require additional check and condition for is item fulfils (see the fix)

Case, adding subscription product with Interval Weekly from frontend.

Request comes to updater and $subscriptionOption = 'subscription' so, on the row 50 code met condition and set variable $createNewSubscriptionOnCheckout = true, The interval was not cleaned.

Case, adding One Time Delivery product from frontend.

The Request comes to updater and $subscriptionOption = 'onetime_purchase', on line 50 the variable doesn't met a condition. The interval will be cleaned.

garthbrantley commented 9 months ago

@eugene-shab What about the case of a recurring order placed by SP via the M2 API?

eugene-shab commented 9 months ago

@eugene-shab What about the case of a recurring order placed by SP via the M2 API?

@garthbrantley As I can see recurring order placed by SP via the M2 API working by another callstack and saving Interval

{
    "subscription_option": {
        "is_fulfilling": true,
        "subscription_id": 4790338,
        "interval": "Weekly",
        "reorder_ordinal": "1",
        "item_added_by_subscribe_pro": true,
        "item_fulfils_subscription": true,
        "next_order_date": "2023-12-07"
    },
    "qty": 1
}

Updater::update() didn't call