Search code examples
phpwordpresswoocommercehook-woocommerce

Customize “one time option” string generated by WooCommerce Subscribe All The Things plugin


Based on Customize “subsription option” string generated by WooCommerce Subscribe All The Things plugin answer code, this is my attempt:

function filter_wcsatt_single_product_subscription_option_description( 
$option_description, $sub_price_html, $has_price_filter, $force_subscription, $product, $subscription_scheme ) {
// Class
$option_price_class = 'subscription-option';

// New description
$option_description = '<span>Subscription: </span> 
<span>' . $sub_price_html . '</span>';

return $option_description;
}
add_filter( 'wcsatt_single_product_subscription_option_description', 'filter_wcsatt_single_product_subscription_option_description', 10, 6 );

Any advice?


Solution

  • This should suffice, basically anything you assign to the $none_string variable will be displayed

    function filter_wcsatt_single_product_one_time_option_description( $none_string, $product ) {
        $none_string = $product->get_price_html();
        
        return $none_string;
    }
    add_filter( 'wcsatt_single_product_one_time_option_description', 'filter_wcsatt_single_product_one_time_option_description', 10, 2 );
    

    The main price above "choose a purchase plan" is added by WooCommerce, and not by the WCSATT plugin. So to hide it, you can use:

    function filter_woocommerce_available_variation( $data, $product, $variation ) {
        $data['price_html'] = '';
        
        return $data;
    }
    add_filter( 'woocommerce_available_variation', 'filter_woocommerce_available_variation', 10, 3 );