Created
April 11, 2016 16:02
-
-
Save vimes1984/508dfbb15658812222a3b9e74f2e298a to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price', 0 ); | |
function add_custom_price( $cart_object ) { | |
$custom_price = 100; // This will be your custome price | |
$cart_object->recurring_cart_key = '2016_10_11_every_3rd_month'; | |
foreach ( $cart_object->cart_contents as $key => $value ) { | |
$value['recurring_cart_key'] = '2016_10_11_every_3rd_month'; | |
$value['next_payment_date'] = '2016-07-11 15:23:20'; | |
$value['data']->parent->subscription_period_interval = '3'; | |
$value['data']->parent->product_custom_fields['_max_variation_period'] = '3'; | |
$value['data']->parent->product_custom_fields['_max_variation_period_interval'] = '3'; | |
$value['data']->parent->product_custom_fields['_subscription_period_interval'] = '3'; | |
$value['data']->price = $custom_price; | |
} | |
echo "<pre>"; | |
var_dump($cart_object->cart_contents['6256c1088a58b28901d15330d8d4fb8e']['data']->parent->subscription_period_interval); | |
echo "</pre>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment