PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

free trail does not work with fixed price

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi Team,

I got into problem when customer order in any other currency than the base currency EURO.

Example :
Customer buy a subscription in Europe get 7 day free trial.
Customer buy from UK did not get free trail and charged immediately.

Any idea what to do?

Hello

Please paste your license key here - https://share.pluginus.net/image/i20210618130558.png -> https://share.pluginus.net/image/i20210618130614.png

Drop me  exact  link to the  issue

if you use fixed prices - yes it may not work because these are prices that do not change - that's the point of fixed prices

Hi Pablo,

I have added the purchase code.

Yes you are right I am using fixed prices which is not supporting subscription free trial.

i am think of using hook

woocommerce_before_calculate_totals

to set the prices for free trial product, do you think its a good idea?

 

unfortunately I don't know, it depends on how the subscription plugin forms the price.  But I think this plugin should have its own hook  for  free trial

this is my solution to the problem. if someone find better way let me know.
Below solution is based on variable subscription  with free_trial attribute. Main thing is minus the price of subscription from cart if it has free trial set.

add_action( 'woocommerce_after_calculate_totals', 'woocommerce_after_calculate_totals_fixed_price_free_trial_fix', 10000000, 1 );
function woocommerce_after_calculate_totals_fixed_price_free_trial_fix(){
    global $WOOCS;
    $cart = WC()->cart;
    $totalBefore = WC()->cart->get_total('noview');
    $total = $totalBefore;
    if(WC_Subscriptions_Cart::cart_contains_subscription() && $WOOCS->current_currency !== $WOOCS->default_currency){
        $recurring_carts = wc()->cart->recurring_carts;
        foreach ($recurring_carts as $cart_item_key => $cart_item) {
            $fixedprice_free_trial = false;
            foreach($cart_item->cart_contents as $cart_item_key1 => $cart_item1){
                if(isset($cart_item1["variation"])){
                    foreach($cart_item1["variation"] as $key => $value){
                        if($key =="attribute_free_trial" && $value ==="true"){
                            $fixedprice_free_trial = true; // if not free trail no need to add the price as cart total already include subscription price
                        }
                    }
                }
                if($fixedprice_free_trial){
                    $itemPrice = $cart_item->get_totals()['total'];
                    $total = $total - $itemPrice;
                }
            }
        }
        if($totalBefore != $total){
            WC()->cart->set_total($total);
        }
    }
}

Hello

Great!  Thank you  for  cooperation!