Last active
May 9, 2026 01:25
-
-
Save rajeshsingh520/9e6c4cba74ca557bfa65db34166430cd to your computer and use it in GitHub Desktop.
This halves the shipping cost in the renewal order of the woocommerce subscription
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'wcs_renewal_order_created', 'pi_modify_renewal_shipping', 10, 2 ); | |
| function pi_modify_renewal_shipping( $renewal_order, $subscription ) { | |
| foreach ( $renewal_order->get_items( 'shipping' ) as $item_id => $shipping_item ) { | |
| $total = (float) $shipping_item->get_total(); | |
| $new_total = $total / 2; | |
| $shipping_item->set_total( $new_total ); | |
| $shipping_item->save(); | |
| } | |
| $renewal_order->calculate_totals( false ); | |
| $renewal_order->save(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment