• Resolved samrot

    (@samrot)


    Hi! How are you? Congrats for this great plugin.
    I added a function to my website to add the word ‘free!’ at the end of each free shipping method when they are available (Ex: ‘Home delivery free!‘) using the filter hook ‘woocommerce_cart_shipping_method_full_label’. It’s working in the shipping calculator in the product page as well as in the cart page but it is not working in the checkout page (it does not shows the word ‘free’ at the end of the free shipping methods that are available), only when one of the free shipping methods gets selected and the shipping method is stored then it shows the word ‘free’ at the end of the shipping method selected but not when is on the list. How can I fix this? Please help

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Diego Versiani

    (@diegoversiani)

    Hi @samrot,

    Fluid Checkout uses a different method to display the shipping methods labels.

    You can use the hooks below to customize it:

    fc_shipping_method_option_label_markup: Changes the label for the shipping method option
    fc_shipping_method_option_description: Changes the text description for the shipping method, displayed right below the option label
    fc_shipping_method_option_description_markup: Changes the markup for the shipping method description, this includes the HTML elements too.
    fc_shipping_method_option_price_markup: Changes text and markup for the price, displayed to the right on shipping methods options

    Best,
    Diego

    • This reply was modified 2 years, 7 months ago by Diego Versiani. Reason: Added missing hook for shipping method description text only
    Thread Starter samrot

    (@samrot)

    Hey Diego! Thanks again for your response.

    I’m using the following code but it’s not working:

    add_filter( 'fc_shipping_method_option_label_markup', 'free_shipping_label_fc', 10, 2 );
    
    function free_shipping_label_fc( $label, $method ) {
    
    if ( $method->method_id == 'local_pickup' ) return $label; //Do not apply to local pickup
    
    	if ( $method->cost == 0 ) {
    		$label .= ' <strong>' . __( 'gratis!', 'woocommerce' ) . '</strong>';
    	}
    	return $label;
    }

    Would you help me fix what’s wrong?
    Thank you in advance.

    Plugin Author Diego Versiani

    (@diegoversiani)

    Hi @samrot,

    The filters currently do not pass/accept the $method parameter, I see now that the filters are not very useful without this parameter.

    I have made the necessary changes to the code and will release an update soon with this change.

    I’ll also send you the working code snippets I used to test the changes, then you can adapt them as you prefer.

    I let you know once the update is available.

    Best,
    Diego

    Thread Starter samrot

    (@samrot)

    Hi Diego!

    Ok, great, thank you so much for this changes.

    When do you think that will be?

    Regards!

    Plugin Author Diego Versiani

    (@diegoversiani)

    Hi @samrot,

    Just a couple of days. Probably tomorrow or the day after.

    Best,
    Diego

    Plugin Author Diego Versiani

    (@diegoversiani)

    Hi @samrot,

    The new version of the Lite plugin is available with the necessary fixes to allow for customizing the shipping methods labels.

    After updating, you’ll need to use one of the code snippets below.

    I recommend you use this first code snippet as it have a layout that is compatible with the other shipping options which have a cost associated with them:

    /**
     * Add price tag "free" to free shipping methods at checkout and cart pages.
     */
    function fluidcheckout_add_free_shipping_price_tag( $label, $method ) {
    	// Bail if method is a local pickup
    	if ( $method->method_id == 'local_pickup' ) { return $label; }
    
    	// Add text to shipping method label
    	if ( $method->cost == 0 ) {
    		$label .= ' <span class="shipping-method__option-price"><strong>' . __( 'Gratis!', 'your-text-domain' ) . '</strong></span>';
    	}
    
    	return $label;
    }
    add_filter( 'fc_shipping_method_option_label_markup', 'fluidcheckout_add_free_shipping_price_tag', 10, 2 );

    Otherwise, if you want to change the “name” of the shipping method, you can use the code snippet below:

    /**
     * Add text "free" to free shipping methods labels at checkout and cart pages.
     */
    function fluidcheckout_add_free_shipping_label( $label, $method ) {
    	// Bail if method is a local pickup
    	if ( $method->method_id == 'local_pickup' ) { return $label; }
    
    	// Add text to shipping method label
    	if ( $method->cost == 0 ) {
    		$label .= ' <strong>' . __( 'gratis!', 'woocommerce' ) . '</strong>';
    	}
    
    	return $label;
    }
    add_filter( 'fc_shipping_method_option_label_markup', 'fluidcheckout_add_free_shipping_label', 10, 2 );

    If you are unsure about how to add the code snippet, check our article:
    How to safely add code snippets to your WooCommerce website

    Best,
    Diego

    Thread Starter samrot

    (@samrot)

    Perfect!! Thx Diego!
    All the best

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘‘free’ text added to free shipping methods dissapears on checkout’ is closed to new replies.