Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
80 stars 29 forks source link

New helper function: wcs_set_recurring_item_total() #627

Closed mattallan closed 1 month ago

mattallan commented 1 month ago

Needed for testing: 4656-gh-woocommerce/woocommerce-subscriptions

Description

This PR turns a private function found in our V3 Subscriptions Controller class into a public helper function: wcs_set_recurring_item_total().

This function is used by both V2 and V3 Subscriptions API Controller classes when implementing the POST orders/123/subscriptions endpoint and is used to make sure the order items copied from the parent order over to the subscription have the correct recurring totals (i.e. the totals do not include sign-up fees or are $0 due to the product including a trial period)

Product impact

mattallan commented 1 month ago

@james-allan as per our slack discussion I've have just pushed up a0365c1611bc4219d12dfe442d8730ec60c4cd43 to check the product is a subscription :) Thanks for the suggestion

james-allan commented 1 month ago

Looks good. I just added an extra test for verifying that simple products are excluded from the function.

mattallan commented 1 month ago

Thanks @james-allan, in the spirit of adding more unit tests, I also added another unit test that ensures line item quantities are handled properly 👍

Merging!