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_filter( 'woocommerce_email_headers', 'add_bcc_all_emails', 10, 2); | |
function add_bcc_all_emails($headers, $object) { | |
$headers = array(); | |
$headers[] = 'Bcc: Name <[email protected]>'; | |
$headers[] = 'Content-Type: text/html'; | |
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 | |
/** | |
* WooCommerce Extra Feature | |
* | |
* Add custom fee to cart automatically | |
* | |
*/ | |
function woo_add_cart_fee() { | |
global $woocommerce; |
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
/** | |
* Auto Complete all WooCommerce orders. | |
*/ | |
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' ); | |
function custom_woocommerce_auto_complete_order( $order_id ) { | |
if ( ! $order_id ) { | |
return; | |
} | |
$order = wc_get_order( $order_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
/* | |
* Hide "Products" in WooCommerce breadcrumb | |
*/ | |
function woo_custom_filter_breadcrumbs_trail ( $trail ) { | |
foreach ( $trail as $k => $v ) { | |
if ( strtolower( strip_tags( $v ) ) == 'products' ) { | |
unset( $trail[$k] ); | |
break; | |
} | |
} |
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
/** | |
* Hide ALL Shipping option when free shipping is available | |
* | |
* @param array $available_methods | |
*/ | |
function hide_all_shipping_when_free_is_available( $available_methods ) { | |
if( isset( $available_methods['free_shipping'] ) ) : | |
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
$coupon_code = 'UNIQUECODE'; // Code | |
$amount = '10'; // Amount | |
$discount_type = 'fixed_cart'; // Type: fixed_cart, percent, fixed_product, percent_product | |
$coupon = array( | |
'post_title' => $coupon_code, | |
'post_content' => '', | |
'post_status' => 'publish', | |
'post_author' => 1, | |
'post_type' => 'shop_coupon' |
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
/** | |
* Custom Add To Cart Messages | |
**/ | |
add_filter( 'woocommerce_add_to_cart_message', 'custom_add_to_cart_message' ); | |
function custom_add_to_cart_message() { | |
global $woocommerce; | |
// Output success messages | |
if (get_option('woocommerce_cart_redirect_after_add')=='yes') : | |
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
/** | |
* Change the add to cart text on single product pages | |
*/ | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' ); | |
function woo_custom_cart_button_text() { | |
global $woocommerce; | |
foreach($woocommerce->cart->get_cart() as $cart_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 fields to edit address page | |
function woo_add_edit_address_fields( $fields ) { | |
$new_fields = array( | |
'date_of_birth' => array( | |
'label' => __( 'Date of birth', 'woocommerce' ), | |
'required' => false, | |
'class' => array( 'form-row' ), | |
), | |
); |
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
//For this example we’ll add some helpful payment instructions to the email, based on the checkout payment type used | |
// https://www.sellwithwp.com/customizing-woocommerce-order-emails/ | |
add_action( 'woocommerce_email_before_order_table', 'add_order_email_instructions', 10, 2 ); | |
function add_order_email_instructions( $order, $sent_to_admin ) { | |
if ( ! $sent_to_admin ) { | |
if ( 'cod' == $order->payment_method ) { | |
// cash on delivery method |
OlderNewer