This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste everything below this line to your theme's functions.php file. | |
add_filter('woocommerce_package_rates', 'round_shipping_price_for_swiss_franc'); | |
function round_shipping_price_for_swiss_franc($rates) | |
{ | |
if (is_array($rates)) { | |
foreach ($rates as $rate) { | |
$rate->cost = ceil($rate->cost / 0.05) * 0.05; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste everything below this line to your theme's functions.php file. | |
add_filter('woocommerce_package_rates', function($rates) { | |
/** @var WC_Shipping_Rate[] $rates */ | |
/** @var WC_Shipping_Rate[] $uniqueRates */ | |
$uniqueRates = array(); | |
foreach ($rates as $key => $rate) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste everything below this line to your theme's functions.php file. | |
add_filter('woocommerce_package_rates', function($rates, $package) { | |
$destination = $package['destination']; | |
// Put postcode, address 1 and address 2 into an array | |
$check_address = array( | |
$destination['address'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste everything below this line to your theme's functions.php file. | |
// Hide shipping option labels. | |
// Example: | |
// — Regular Shipping: $20 => $20 | |
// — Express Shipping: $30 => $30 | |
// — Free Shipping => Free | |
add_filter('woocommerce_cart_shipping_method_full_label', function($label) { | |
@list(, $price) = explode(':', $label); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste everything below this line to your child-theme's functions.php file. | |
// Cut shipping option ids if they exceed 50-chars length. | |
add_filter('woocommerce_package_rates', function ($rates) { | |
$shortened = array(); | |
foreach ($rates as $rate_id => $rate) { | |
$rate_id = substr($rate_id, 0, 50); | |
$rate->id = $rate_id; | |
$shortened[$rate_id] = $rate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste everything below this line to your theme's functions.php file. | |
// Hide free shipping options prices. | |
// Example: | |
// — Free Shipping: $0.00 => Free Shipping | |
// — Regular Shipping: $20 => Regular Shipping: $20 | |
add_filter('woocommerce_cart_shipping_method_full_label', function($label, WC_Shipping_Rate $rate) { | |
if (isset($rate->cost) && (float)$rate->cost === 0.0) { | |
list($label,) = explode(':', $label, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste everything below this line to your child-theme's functions.php file. | |
// Transforms | |
// >> Shipping Option Name (shipping option description): $99 | |
// to | |
// >> Shipping Option Name: $99<br> | |
// >> <small>shipping option description</small> | |
add_filter('woocommerce_cart_shipping_method_full_label', function($label, $method) { | |
if (($open = strpos($label, '(')) !== false && |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste everything below this line to your child-theme's functions.php file. | |
// Exclude product attributes from the 'Contains' condition. | |
add_filter('woocommerce_attribute_taxonomies', function($taxs) { | |
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10); | |
foreach ($backtrace as $call) { | |
if (isset($call['file']) && preg_match('#wc-tree-table-rate-shipping(/|\\\\)tpl.php#', $call['file'])) { | |
return []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste everything below this line to your child-theme's functions.php file. | |
// Tree Table Rate Shipping: pass non-shippable (virtual, etc) items as well to shipping rules. | |
add_filter('trs_include_non_shippable_items', '__return_true'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste everything below this line to your child-theme's functions.php file. | |
// Renames any shipping option titled exactly 'Weight Based Shipping' to 'Shipping'. | |
add_filter('woocommerce_shipping_method_add_rate_args', function($rateArgs) { | |
if (isset($rateArgs['label']) && $rateArgs['label'] === 'Weight Based Shipping') { | |
$rateArgs['label'] = 'Shipping'; | |
} | |
return $rateArgs; | |
}); |
OlderNewer