Display a delivery day range based on shipping country in WoocommerceWooCommerce: Programmatically changing the default shipping methodWoocommerce custom shipping by country and number of productsDisplay an estimated delivery date range based on WooCommerce cart item stockAdd different custom labels to Woocommerce shipping methodshow to get the shipping method name woocommerceTax rounding issue when having multiple tax classes in woocommerceHide specific shipping options based on products or categories in WooCommerceDisable specific payment methods for specific shipping zones when cart subtotal reach a specific amount in WoocommerceDisplay a custom message based on shipping zone and product categories in Woocommerce“includes $x VAT estimated for country ”in WooCommerce cart and checkout

Western buddy movie with a supernatural twist where a woman turns into an eagle at the end

Why is the 'in' operator throwing an error with a string literal instead of logging false?

How do conventional missiles fly?

How to say in German "enjoying home comforts"

Why are electrically insulating heatsinks so rare? Is it just cost?

Is it legal for company to use my work email to pretend I still work there?

Is it unprofessional to ask if a job posting on GlassDoor is real?

A reference to a well-known characterization of scattered compact spaces

Stopping power of mountain vs road bike

Could gravitational lensing be used to protect a spaceship from a laser?

Can a rocket refuel on Mars from water?

Anagram holiday

What is the word for reserving something for yourself before others do?

Blender 2.8 I can't see vertices, edges or faces in edit mode

What's the point of deactivating Num Lock on login screens?

What is the intuition behind short exact sequences of groups; in particular, what is the intuition behind group extensions?

AES: Why is it a good practice to use only the first 16bytes of a hash for encryption?

Is "remove commented out code" correct English?

SSH "lag" in LAN on some machines, mixed distros

Why is Collection not simply treated as Collection<?>

How to take photos in burst mode, without vibration?

How to show the equivalence between the regularized regression and their constraint formulas using KKT

90's TV series where a boy goes to another dimension through portal near power lines

I'm flying to France today and my passport expires in less than 2 months



Display a delivery day range based on shipping country in Woocommerce


WooCommerce: Programmatically changing the default shipping methodWoocommerce custom shipping by country and number of productsDisplay an estimated delivery date range based on WooCommerce cart item stockAdd different custom labels to Woocommerce shipping methodshow to get the shipping method name woocommerceTax rounding issue when having multiple tax classes in woocommerceHide specific shipping options based on products or categories in WooCommerceDisable specific payment methods for specific shipping zones when cart subtotal reach a specific amount in WoocommerceDisplay a custom message based on shipping zone and product categories in Woocommerce“includes $x VAT estimated for country ”in WooCommerce cart and checkout






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















In Woocommerce, I'm trying to add an estimated delivery day range on cart and checkout pages.

I have set 2 shipping Zones: Germany and other European countries (outside Germany) called "DHL Europe". I need to display a different delivery day range for Germany shipping country than other European shipping countries:



  • Germany shipping country will display "Lieferzeit 3-5 Werktage" (and when there is no shipping costs).

  • Other European shipping countries will display "Lieferzeit 5-7 Werktage"

My code attempt:



function sv_shipping_method_estimate_label( $label, $method ) 
$label .= '<br /><small class="subtotal-tax">';
switch ( $method->method_id )
case 'flat_rate':
$label .= 'Lieferzeit 3-5 Werktage';
break;
case 'free_shipping':
$label .= 'Lieferzeit 3-5 Werktage';
break;
case 'international_delivery':
$label .= 'Lieferzeit 5-7 Werktage';


$label .= '</small>';
return $label;

add_filter( 'woocommerce_cart_shipping_method_full_label', 'sv_shipping_method_estimate_label', 10, 2 );


It works with the free_shipping and flat_rate shipping methods, but not for European deliveries (outside Germany).



What am I doing wrong?

How to display the correct date range for European countries (outside Germany)?










share|improve this question
























  • Do a var_dump($method->method_id); before your switch and see if it really contains what you think it does/should.

    – Dave
    Mar 21 at 18:37

















2















In Woocommerce, I'm trying to add an estimated delivery day range on cart and checkout pages.

I have set 2 shipping Zones: Germany and other European countries (outside Germany) called "DHL Europe". I need to display a different delivery day range for Germany shipping country than other European shipping countries:



  • Germany shipping country will display "Lieferzeit 3-5 Werktage" (and when there is no shipping costs).

  • Other European shipping countries will display "Lieferzeit 5-7 Werktage"

My code attempt:



function sv_shipping_method_estimate_label( $label, $method ) 
$label .= '<br /><small class="subtotal-tax">';
switch ( $method->method_id )
case 'flat_rate':
$label .= 'Lieferzeit 3-5 Werktage';
break;
case 'free_shipping':
$label .= 'Lieferzeit 3-5 Werktage';
break;
case 'international_delivery':
$label .= 'Lieferzeit 5-7 Werktage';


$label .= '</small>';
return $label;

add_filter( 'woocommerce_cart_shipping_method_full_label', 'sv_shipping_method_estimate_label', 10, 2 );


It works with the free_shipping and flat_rate shipping methods, but not for European deliveries (outside Germany).



What am I doing wrong?

How to display the correct date range for European countries (outside Germany)?










share|improve this question
























  • Do a var_dump($method->method_id); before your switch and see if it really contains what you think it does/should.

    – Dave
    Mar 21 at 18:37













2












2








2


1






In Woocommerce, I'm trying to add an estimated delivery day range on cart and checkout pages.

I have set 2 shipping Zones: Germany and other European countries (outside Germany) called "DHL Europe". I need to display a different delivery day range for Germany shipping country than other European shipping countries:



  • Germany shipping country will display "Lieferzeit 3-5 Werktage" (and when there is no shipping costs).

  • Other European shipping countries will display "Lieferzeit 5-7 Werktage"

My code attempt:



function sv_shipping_method_estimate_label( $label, $method ) 
$label .= '<br /><small class="subtotal-tax">';
switch ( $method->method_id )
case 'flat_rate':
$label .= 'Lieferzeit 3-5 Werktage';
break;
case 'free_shipping':
$label .= 'Lieferzeit 3-5 Werktage';
break;
case 'international_delivery':
$label .= 'Lieferzeit 5-7 Werktage';


$label .= '</small>';
return $label;

add_filter( 'woocommerce_cart_shipping_method_full_label', 'sv_shipping_method_estimate_label', 10, 2 );


It works with the free_shipping and flat_rate shipping methods, but not for European deliveries (outside Germany).



What am I doing wrong?

How to display the correct date range for European countries (outside Germany)?










share|improve this question
















In Woocommerce, I'm trying to add an estimated delivery day range on cart and checkout pages.

I have set 2 shipping Zones: Germany and other European countries (outside Germany) called "DHL Europe". I need to display a different delivery day range for Germany shipping country than other European shipping countries:



  • Germany shipping country will display "Lieferzeit 3-5 Werktage" (and when there is no shipping costs).

  • Other European shipping countries will display "Lieferzeit 5-7 Werktage"

My code attempt:



function sv_shipping_method_estimate_label( $label, $method ) 
$label .= '<br /><small class="subtotal-tax">';
switch ( $method->method_id )
case 'flat_rate':
$label .= 'Lieferzeit 3-5 Werktage';
break;
case 'free_shipping':
$label .= 'Lieferzeit 3-5 Werktage';
break;
case 'international_delivery':
$label .= 'Lieferzeit 5-7 Werktage';


$label .= '</small>';
return $label;

add_filter( 'woocommerce_cart_shipping_method_full_label', 'sv_shipping_method_estimate_label', 10, 2 );


It works with the free_shipping and flat_rate shipping methods, but not for European deliveries (outside Germany).



What am I doing wrong?

How to display the correct date range for European countries (outside Germany)?







php wordpress woocommerce country shipping-method






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 22:46









LoicTheAztec

96.2k1371113




96.2k1371113










asked Mar 21 at 18:30









limilolimilo

1028




1028












  • Do a var_dump($method->method_id); before your switch and see if it really contains what you think it does/should.

    – Dave
    Mar 21 at 18:37

















  • Do a var_dump($method->method_id); before your switch and see if it really contains what you think it does/should.

    – Dave
    Mar 21 at 18:37
















Do a var_dump($method->method_id); before your switch and see if it really contains what you think it does/should.

– Dave
Mar 21 at 18:37





Do a var_dump($method->method_id); before your switch and see if it really contains what you think it does/should.

– Dave
Mar 21 at 18:37












1 Answer
1






active

oldest

votes


















1














You don't really need to target your shipping methods, but instead customer shipping country:



add_filter( 'woocommerce_cart_shipping_method_full_label', 'cart_shipping_method_full_label_filter', 10, 2 );
function cart_shipping_method_full_label_filter( $label, $method )
// The targeted country code
$targeted_country_code = 'DE';

if( WC()->customer->get_shipping_country() !== $targeted_country_code )
$days_range = '5-7'; // International
else
$days_range = '3-5'; // Germany

return $label . '<br /><small class="subtotal-tax">' . sprintf( __("Lieferzeit %s Werktage"), $days_range ) . '</small>';



Code goes on function.php file of your active child theme (or active theme). Tested and works.






share|improve this answer

























  • Thx for the help but with your code it's hiding the shipping label and the costs Before: s16.directupload.net/images/190321/e5x2hs4i.png after s17.directupload.net/images/190321/dn6twqpi.png

    – limilo
    Mar 21 at 21:52











  • @limilo Sorry a mistake… I have updated the code.

    – LoicTheAztec
    Mar 21 at 21:54






  • 1





    made my day. Allways a pleasure

    – limilo
    Mar 21 at 21:59











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55287041%2fdisplay-a-delivery-day-range-based-on-shipping-country-in-woocommerce%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You don't really need to target your shipping methods, but instead customer shipping country:



add_filter( 'woocommerce_cart_shipping_method_full_label', 'cart_shipping_method_full_label_filter', 10, 2 );
function cart_shipping_method_full_label_filter( $label, $method )
// The targeted country code
$targeted_country_code = 'DE';

if( WC()->customer->get_shipping_country() !== $targeted_country_code )
$days_range = '5-7'; // International
else
$days_range = '3-5'; // Germany

return $label . '<br /><small class="subtotal-tax">' . sprintf( __("Lieferzeit %s Werktage"), $days_range ) . '</small>';



Code goes on function.php file of your active child theme (or active theme). Tested and works.






share|improve this answer

























  • Thx for the help but with your code it's hiding the shipping label and the costs Before: s16.directupload.net/images/190321/e5x2hs4i.png after s17.directupload.net/images/190321/dn6twqpi.png

    – limilo
    Mar 21 at 21:52











  • @limilo Sorry a mistake… I have updated the code.

    – LoicTheAztec
    Mar 21 at 21:54






  • 1





    made my day. Allways a pleasure

    – limilo
    Mar 21 at 21:59















1














You don't really need to target your shipping methods, but instead customer shipping country:



add_filter( 'woocommerce_cart_shipping_method_full_label', 'cart_shipping_method_full_label_filter', 10, 2 );
function cart_shipping_method_full_label_filter( $label, $method )
// The targeted country code
$targeted_country_code = 'DE';

if( WC()->customer->get_shipping_country() !== $targeted_country_code )
$days_range = '5-7'; // International
else
$days_range = '3-5'; // Germany

return $label . '<br /><small class="subtotal-tax">' . sprintf( __("Lieferzeit %s Werktage"), $days_range ) . '</small>';



Code goes on function.php file of your active child theme (or active theme). Tested and works.






share|improve this answer

























  • Thx for the help but with your code it's hiding the shipping label and the costs Before: s16.directupload.net/images/190321/e5x2hs4i.png after s17.directupload.net/images/190321/dn6twqpi.png

    – limilo
    Mar 21 at 21:52











  • @limilo Sorry a mistake… I have updated the code.

    – LoicTheAztec
    Mar 21 at 21:54






  • 1





    made my day. Allways a pleasure

    – limilo
    Mar 21 at 21:59













1












1








1







You don't really need to target your shipping methods, but instead customer shipping country:



add_filter( 'woocommerce_cart_shipping_method_full_label', 'cart_shipping_method_full_label_filter', 10, 2 );
function cart_shipping_method_full_label_filter( $label, $method )
// The targeted country code
$targeted_country_code = 'DE';

if( WC()->customer->get_shipping_country() !== $targeted_country_code )
$days_range = '5-7'; // International
else
$days_range = '3-5'; // Germany

return $label . '<br /><small class="subtotal-tax">' . sprintf( __("Lieferzeit %s Werktage"), $days_range ) . '</small>';



Code goes on function.php file of your active child theme (or active theme). Tested and works.






share|improve this answer















You don't really need to target your shipping methods, but instead customer shipping country:



add_filter( 'woocommerce_cart_shipping_method_full_label', 'cart_shipping_method_full_label_filter', 10, 2 );
function cart_shipping_method_full_label_filter( $label, $method )
// The targeted country code
$targeted_country_code = 'DE';

if( WC()->customer->get_shipping_country() !== $targeted_country_code )
$days_range = '5-7'; // International
else
$days_range = '3-5'; // Germany

return $label . '<br /><small class="subtotal-tax">' . sprintf( __("Lieferzeit %s Werktage"), $days_range ) . '</small>';



Code goes on function.php file of your active child theme (or active theme). Tested and works.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 21 at 21:54

























answered Mar 21 at 19:22









LoicTheAztecLoicTheAztec

96.2k1371113




96.2k1371113












  • Thx for the help but with your code it's hiding the shipping label and the costs Before: s16.directupload.net/images/190321/e5x2hs4i.png after s17.directupload.net/images/190321/dn6twqpi.png

    – limilo
    Mar 21 at 21:52











  • @limilo Sorry a mistake… I have updated the code.

    – LoicTheAztec
    Mar 21 at 21:54






  • 1





    made my day. Allways a pleasure

    – limilo
    Mar 21 at 21:59

















  • Thx for the help but with your code it's hiding the shipping label and the costs Before: s16.directupload.net/images/190321/e5x2hs4i.png after s17.directupload.net/images/190321/dn6twqpi.png

    – limilo
    Mar 21 at 21:52











  • @limilo Sorry a mistake… I have updated the code.

    – LoicTheAztec
    Mar 21 at 21:54






  • 1





    made my day. Allways a pleasure

    – limilo
    Mar 21 at 21:59
















Thx for the help but with your code it's hiding the shipping label and the costs Before: s16.directupload.net/images/190321/e5x2hs4i.png after s17.directupload.net/images/190321/dn6twqpi.png

– limilo
Mar 21 at 21:52





Thx for the help but with your code it's hiding the shipping label and the costs Before: s16.directupload.net/images/190321/e5x2hs4i.png after s17.directupload.net/images/190321/dn6twqpi.png

– limilo
Mar 21 at 21:52













@limilo Sorry a mistake… I have updated the code.

– LoicTheAztec
Mar 21 at 21:54





@limilo Sorry a mistake… I have updated the code.

– LoicTheAztec
Mar 21 at 21:54




1




1





made my day. Allways a pleasure

– limilo
Mar 21 at 21:59





made my day. Allways a pleasure

– limilo
Mar 21 at 21:59



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55287041%2fdisplay-a-delivery-day-range-based-on-shipping-country-in-woocommerce%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript