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 // only copy if needed | |
/** | |
* Change cart price display for free products | |
* | |
* @param string $price_html the price display html | |
* @param \WC_Product | |
* @return string - updated pricing html | |
*/ | |
function sv_wc_free_cart_price( $price_html, $product ) { |
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 // Use only if required | |
// Custom snippet to add TNT Shipping Functionality for the WooCommerce Shipment Traciking Plugin. | |
add_filter( 'wc_shipment_tracking_get_providers', '_wc_shipment_tracking_tnt_express_domestic' ); | |
function _wc_shipment_tracking_tnt_express_domestic( $providers ) { | |
$providers['United Kingdom']['TNT Express domestic (consignment)'] = 'https://www.tnt.com/webtracker/tracking.do?cons=%1$s&trackType=CON&respLang=en&respCountry=gb&sourceCountry=gb&requestType=GEN&searchType=CON'; | |
return $providers; | |
} |
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 | |
/* Add this to your theme's functions.php to move the variation description display to a different location | |
* on the product page. | |
*/ | |
add_action('plugins_loaded', 'move_variation_description', 50); | |
function move_variation_description(){ | |
// Remove the hook from the original location |
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
woocommerce_after_add_to_cart_button |
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 // Use only if required. | |
if ( ! function_exists( 'my_custom_event_function' ) ) { | |
function my_custom_event_function() { | |
wc_google_analytics_pro()->get_integration()->custom_event( 'onBannerClick', array( | |
'hitType' => 'event', | |
'eventCategory' => 'Outbound Link', | |
'eventAction' => 'click', | |
'eventLabel' => 'Shopping-Banner', | |
'eventValue' => null, |
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
/* | |
This code snippet reorders the shipping methods in your WooCommerce website, | |
in an ascending order in terms of shipping costs. | |
Copy the content to your theme's functions.php file or use a custom code snippet plugin | |
like this one: https://github.com/woocommerce/theme-customisations to prevent the code | |
from being overwritten during theme updates. | |
*/ | |
add_filter( 'woocommerce_package_rates' , 'reorder_shipping_methods', 10, 2 ); | |
function reorder_shipping_methods( $rates, $package ) { |
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 // Remove this if not required. | |
add_filter( 'wc_shipment_tracking_get_providers', 'custom_woocommerce_shipment_tracking_provider' ); | |
function custom_woocommerce_shipment_tracking_provider( $provider ) { | |
$provider = array( | |
'United States' => array( | |
'UPS' | |
=> 'http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=%1$s', |
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 | |
// usage example: Current Stock: [product_stock id="2525"] | |
add_shortcode('product_stock', 'product_stock'); | |
function product_stock( $atts ) { | |
if ( ! $atts['id'] ) { | |
return ''; | |
} | |
$product = get_product($atts['id']); | |
return (int)$product->stock; // prints 19, ie the quantity of product 2525 |
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 | |
// Shortcode to get variation stock. usage example: Current Stock: [variation_stock id="2525"] | |
// The id being entered should be that of the variation, not the product. | |
add_shortcode('variation_stock', 'variation_stock'); | |
function variation_stock( $atts ) { | |
if ( ! $atts['id'] ) { | |
return ''; | |
} |
OlderNewer