I need your help. I want to rename the word “Free shipping” option on woocommerce when wholesale checkbox is checked with “Hello” and when it is unchecked I want to display “Hi”. Below is the html I took from the site.
<td data-children-count="1">
<input type="checkbox" name="wcs_wholesale_customer" id="wcs_wholesale_customer" value="1" checked="checked">Check this option to set this user to receive your wholesale pricing<br>
<!-- <span class="description"></span> -->
</td>
and this is the function I added on functions.php
function sww_wc_free_shipping_label( $label ) {
if(isset( $_POST['wcs_wholesale_customer']) && is_cart() && is_checkout() ) {
$label = 'Hello';
} else {
$label = 'Hi';
}
return $label;
}
add_filter( 'woocommerce_cart_shipping_method_full_label', 'sww_wc_free_shipping_label', 10, 2 );
Please can you check what needs to be changed on these code above?
2
Answers
I finally sort out with the php code below:
Thanks guys.
This is possible with HTML and CSS. check out what I did here:
As for doing it the PHP way, you can check if the checkbox was checked using code like this:
<?php
if( empty($_POST["wcs_wholesale_customer"]) ) { echo "Checkbox was left unchecked."; }
else { echo "Checkbox was checked."; }
?>