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_countries', 'rs_edit_pk_country' ); | |
function rs_edit_pk_country ( $countries ) { | |
$new_countries = array( | |
'PK' => __( 'Pakistan', 'woocommerce' ), | |
); | |
return array_merge( $countries, $new_countries ); | |
} | |
add_filter( 'woocommerce_continents', 'rs_add_new_pk_country_to_continents' ); |
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_cart_tax_totals', 'show_zero_rate_taxes' ); | |
function show_zero_rate_taxes( $tax_totals ) { | |
if ( empty( $tax_totals ) && WC()->customer->is_vat_exempt() ) { | |
$tax_totals['zero-rated'] = (object) array( | |
'label' => 'Zero Rated Tax', | |
'amount' => 0, | |
'formatted_amount' => wc_price( 0 ), | |
'name' => 'Zero Rated Tax', |
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_action( 'woocommerce_before_shop_loop_item_title', 'add_category_title', 25); | |
function add_category_title() | |
{ | |
global $product; | |
$product_cats = wp_get_post_terms($product->get_id(), 'product_cat'); | |
$count = count($product_cats); | |
foreach($product_cats as $key => $cat) | |
{ | |
echo | |
'<span class="wcc_category_title"> |
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_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 ); | |
function remove_add_to_cart_buttons() { | |
// replace a_category and another_category with the slugs of the categories you'd like to have the button removed from | |
if( is_product_category( array( 'a_category', 'another_category'))) { | |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); | |
} | |
} | |
// Did this help? Donate me some BTC: 1BEsm8VMkYhSFJ92cvUYwxCtsfsB2rBfiG |
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
function woo_ninja_remove_price_range( $price, $product ) { | |
// Main Price | |
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) ); | |
$price = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] ); | |
// Sale Price | |
$prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) ); | |
sort( $prices ); | |
$saleprice = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] ); |
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_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_stock', 10 ); | |
function woocommerce_template_loop_stock() { | |
global $product; | |
if ( ! $product->managing_stock() && ! $product->is_in_stock() ) | |
echo '<p class="stock out-of-stock">SOLD</p>'; | |
} |
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
function my_custom_add_to_cart_redirect( $url ) { | |
$url = WC()->cart->get_checkout_url(); | |
// $url = wc_get_checkout_url(); // since WC 2.5.0 | |
return $url; | |
} | |
add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' ); |
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_package_rates' , 'sort_woocommerce_available_shipping_methods_by_cost', 10, 2 ); | |
function sort_woocommerce_available_shipping_methods_by_cost( $rates, $package ) { | |
if ( ! $rates ) { | |
return; | |
} | |
$tmp = array(); | |
foreach( $rates as $rate ) { | |
$tmp[] = $rate->cost; | |
} |
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
// Place the following code in your theme's functions.php file to add the shipping method to ALL emails | |
add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_method_to_emails', 15, 2 ); | |
function wc_add_shipping_method_to_emails( $order, $is_admin_email ) { | |
echo '<p><strong>Shipping Method:</strong> ' . $order->get_shipping_method() . '</p>'; | |
} | |
// Place the following code in your theme's functions.php file to add the shipping method to ADMIN emails only | |
add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_method_to_admin_emails', 15, 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 | |
/** | |
* New order email | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
// allowed tags for escaping | |
$allowed_tags = array( |
NewerOlder