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
add_filter( 'woocommerce_get_availability', 'wcs_custom_get_availability', 1, 2); | |
function wcs_custom_get_availability( $availability, $_product ) { | |
// Change Out of Stock Text | |
if ( ! $_product->is_in_stock() ) { | |
$availability['availability'] = __('Sold Out', 'woocommerce'); | |
} | |
return $availability; | |
} |
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
//Code to increase the excerpt length in WordPress. | |
function custom_excerpt_length( $length ) { | |
return 100; // This is the number of words. | |
} | |
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); |
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 this line if needed | |
/** | |
* Filter the document table headers to add a product thumbnail header | |
* | |
* @param array $table_headers Table column headers | |
* @return array The updated table column headers | |
*/ | |
function sv_wc_pip_document_table_headers_product_thumbnail( $table_headers ) { | |
$thumbnail_header = array( 'product_thumbnail' => 'Thumbnail' ); | |
// add product thumnail column as the first column |
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 this line if needed | |
/** | |
* Remove the tracking code added by WooCommerce Google Analytics Pro | |
* - this is usefull if your theme or another plugin is adding the tracking code | |
* - and you wish to use that instead | |
*/ | |
function sv_wc_google_analytics_pro_remove_tracking_code() { | |
// check if Google Analytics Pro is active | |
if ( ! function_exists( 'wc_google_analytics_pro' ) ) { | |
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
.single-product div.product form.cart .button { | |
float: left; | |
} |
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 ''; | |
} |
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 // 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
/* | |
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 ) { |