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
/** | |
* wc_shipment_tracking_add_custom_provider | |
* | |
* Adds custom provider to shipment tracking or add existing providers to another country. | |
* | |
* Change the country name, the provider name, and the URL (it must include the %1$s) | |
* Add one provider per line | |
*/ | |
add_filter( 'wc_shipment_tracking_get_providers' , 'wc_shipment_tracking_add_custom_provider' ); |
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_shipment_tracking_default_provider', 'custom_woocommerce_shipment_tracking_default_provider' ); | |
function custom_woocommerce_shipment_tracking_default_provider( $provider ) { | |
$provider = 'USPS'; | |
return $provider; | |
} |
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( 'wc_shipment_tracking_get_providers', 'custom_shipment_tracking' ); | |
function custom_shipment_tracking( $providers ) { | |
unset($providers['Australia']); | |
unset($providers['Austria']); | |
unset($providers['Brazil']); | |
unset($providers['Belgium']); | |
unset($providers['Canada']); | |
unset($providers['Czech Republic']); |
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 custom column headers | |
function wc_csv_export_modify_column_headers( $column_headers ) { | |
$new_headers = array( | |
'column_1' => 'Column 1', | |
'column_2' => 'Column 2', | |
// add other column headers here in the format column_key => Column Name | |
); | |
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
/** | |
* Hides checkout fields based on the products in the cart | |
* | |
* @param array $fields | |
* @return array | |
*/ | |
function conditional_checkout_fields_products( $fields ) { | |
$cart = WC()->cart->get_cart(); | |
foreach ( $cart as $item_key => $values ) { |
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
// Enable WP_DEBUG mode | |
define('WP_DEBUG', true); | |
// Enable Debug logging to the /wp-content/debug.log file | |
define('WP_DEBUG_LOG', true); | |
// Disable display of errors and warnings | |
define('WP_DEBUG_DISPLAY', false); | |
@ini_set('display_errors',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_single_product_summary', 'wc_custom_show_attributes_outside_tabs', 35 ); | |
function wc_custom_show_attributes_outside_tabs() { | |
global $product; | |
$product->list_attributes(); | |
} |
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( 'updated_users_subscriptions_for_order', 'wc_subs_suspend_on_cod' ); | |
function wc_subs_suspend_on_cod( $order ) { | |
if ( ! is_object( $order ) ) { | |
$order = new WC_Order( $order ); | |
} | |
foreach ( WC_Subscriptions_Order::get_recurring_items( $order ) as $order_item ) { | |
$subscription_key = WC_Subscriptions_Manager::get_subscription_key( $order->id, WC_Subscriptions_Order::get_items_product_id( $order_item ) ); |
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_eu_vat_number_country_codes', 'woo_custom_eu_vat_number_country_codes' ); | |
function woo_custom_eu_vat_number_country_codes( $vat_countries ) { | |
$display_vat = array_diff($vat_countries, ['SE', 'GB']); // remove countries in second array | |
return array_values($display_vat); // reindex array | |
} |