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_checkout_process', 'wc_minimum_order_amount' ); | |
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' ); | |
function wc_minimum_order_amount() { | |
// Set this variable to specify a minimum order value | |
$minimum = 50; | |
if ( WC()->cart->total < $minimum ) { | |
if( is_cart() ) { |
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 | |
/** | |
* Sell only in Minas Gerais. Brazil | |
*/ | |
function wc_sell_only_states( $states ) { | |
$states['BR'] = array( | |
'MG' => __( 'Minas Gerais', 'woocommerce' ), | |
); | |
return $states; |
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_add_to_cart_redirect', 'wc_custom_cart_redirect' ); | |
function wc_custom_cart_redirect() { | |
return get_permalink( wc_get_page_id( 'shop' ) ); | |
} |
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 | |
function my_theme_woocommerce_enqueue_styles( $styles ) { | |
$base_url = str_replace( array( 'http:', 'https:' ), '', get_stylesheet_directory_uri() ) . '/inc/woocommerce/css/'; | |
$styles['woocommerce-layout']['src'] = $base_url . 'woocommerce-layout.css'; | |
$styles['woocommerce-smallscreen']['src'] = $base_url . 'woocommerce-smallscreen.css'; | |
$styles['woocommerce-general']['src'] = $base_url . 'woocommerce.css'; | |
return $styles; |
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
/** | |
* Set the store base city and postcode / zipcode | |
*/ | |
add_filter( 'woocommerce_countries_base_city' , 'set_woocommerce_countries_base_city' ); | |
function set_woocommerce_countries_base_city() { | |
// Replace with your store town/city | |
return 'Townland'; | |
} | |
add_filter( 'woocommerce_countries_base_postcode' , 'set_woocommerce_countries_base_postcode' ); |
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
/** | |
* Delete ALL WooCommerce tax rates | |
* | |
* Add to your theme functions.php then go to woocommerce -> system status -> tools and there will be a delete all tax rates button http://cld.wthms.co/tXvp | |
*/ | |
add_filter( 'woocommerce_debug_tools', 'custom_woocommerce_debug_tools' ); | |
function custom_woocommerce_debug_tools( $tools ) { | |
$tools['woocommerce_delete_tax_rates'] = array( |
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_product_options_pricing','custom_cost_price'); | |
function custom_cost_price() { | |
woocommerce_wp_text_input( array( 'id' => '_cost_price', 'class' => 'wc_input_price short', 'label' => __( 'Cost Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol().')', 'type' => 'number', 'custom_attributes' => array( | |
'step' => 'any', | |
'min' => '0' | |
) ) ); | |
} | |
add_action('woocommerce_process_product_meta_simple', 'save_custom_cost_price'); | |
function save_custom_cost_price($post_id) { |
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_checkout_validation', 'deny_pobox_postcode'); | |
function deny_pobox_postcode( $posted ) { | |
global $woocommerce; | |
$address = ( isset( $posted['shipping_address_1'] ) ) ? $posted['shipping_address_1'] : $posted['billing_address_1']; | |
$postcode = ( isset( $posted['shipping_postcode'] ) ) ? $posted['shipping_postcode'] : $posted['billing_postcode']; | |
$replace = array(" ", ".", ","); | |
$address = strtolower( str_replace( $replace, '', $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 | |
/** | |
* Add login / logout links to any menu and position it | |
* Based On : http://www.viper007bond.com/2011/09/20/code-snippet-add-a-link-to-latest-post-to-wordpress-nav-menu/ | |
* | |
* Instructions : | |
* 1 - Add this code to your theme functions file | |
* 2 - create a new custom menu item : http://cl.ly/image/092k303O3C2z DO NOT change this #loginlogout | |
* 3 - Position the menu item where ever you would like it to appear : http://cl.ly/image/0p00131v1L09 | |
**/ |
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 login link to my account menu. | |
* | |
* Add this to your theme functions file | |
*/ | |
add_filter( 'wp_nav_menu_items', 'woocommerce_nav_menu_items_login', 10, 2 ); | |
function woocommerce_nav_menu_items_login( $items, $args ) { | |
if ( get_option('woocommerce_menu_logout_link')=='yes' && strstr($items, get_permalink(woocommerce_get_page_id('myaccount'))) && !is_user_logged_in() ) |
OlderNewer