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('template_redirect', 'wc_custom_redirect_after_purchase'); | |
function wc_custom_redirect_after_purchase() { | |
global $wp; | |
if (is_checkout() && !empty($wp->query_vars['order-received'])) { | |
$order = new WC_Order($wp->query_vars['order-received']); | |
$quantity = 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_available_payment_gateways', 'xa_change_optins_based_on_user_role'); | |
function xa_change_optins_based_on_user_role(){ | |
global $woocommerce; | |
// Check with the capability which is unique to the particular user role. | |
if( current_user_can( 'edit_posts' ) { | |
// | |
if ( isset( $available_gateways['ccavenue'] ) && $woocommerce->customer->get_country() <> 'IN' ) { | |
unset( $available_gateways['ccavenue'] ); | |
} else if ( isset( $available_gateways['paypal'] ) && $woocommerce->customer->get_country() == 'IN' ) { | |
unset( $available_gateways['paypal'] ); |
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_email_order_meta_keys', 'xa_email_custom_order_meta_keys'); | |
function xa_email_custom_order_meta_keys( $field_keys ) { | |
// Please make sure the Custom Field 'tracking_code' is added to the Checkout Field. | |
$field_keys[] = 'tracking_code'; | |
return $field_keys; | |
} |
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_order_notes', 'xa_new_custom_checkout_field' ); | |
function xa_new_custom_checkout_field( $checkout ) { | |
echo '<div id="xa_new_custom_checkout_field"><h2>' . __('SSN') . '</h2>'; | |
woocommerce_form_field( 'new_field_ssn', array( | |
'type' => 'text', | |
'class' => array('ssn-field-class form-row-wide'), | |
'label' => __('SSN Number'), | |
'placeholder' => __('Enter SSN'), |
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_billing_fields', 'xa_filter_billing_phone', 10, 1 ); | |
function xa_filter_billing_phone( $address_fields ) { | |
$address_fields['billing_phone']['required'] = false; | |
return $address_fields; | |
} |
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_checkout_fields' , 'xa_override_existing_checkout_fields' ); | |
function xa_override_existing_checkout_fields( $fields ) { | |
$fields['order']['order_comments']['placeholder'] = 'Let us know your color preference.'; | |
$fields['order']['order_comments']['label'] = 'Gift Wrap Preference'; | |
return $fields; | |
} |
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('hf_csv_order_post_additional_columns', 'woocommerce_csv_order_post_add_additional_columns', 10, 1); | |
function woocommerce_csv_order_post_add_additional_columns($additional_meta) { | |
$additional_meta = array( | |
'pdf_invoice_num' => '_invoice_number_display', | |
'Payer PayPal address' => 'Payer PayPal address', | |
'PayPal Transaction Fee' => 'PayPal Transaction Fee' | |
); | |
return $additional_meta; |
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( 'eh_pklist_label_add_additional_information', 'add_eh_pklist_label_add_tracking_number', 10 , 1 ); | |
function add_eh_pklist_label_add_tracking_number($fromaddress) | |
{ | |
$tracking_number = '78965413301236547893210'; // Change this to desired one. | |
$ship_date = '27-08-2016'; // Change it to desired one. | |
$fromaddress['tracking_number'] = $tracking_number; | |
$fromaddress['ship_date'] = $ship_date; | |
return $fromaddress; | |
} |
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( 'wf_pklist_label_add_additional_information', 'wf_pklist_add_tracking_number', 10 , 1 ); | |
function wf_pklist_add_tracking_number($order_additional_information) | |
{ | |
$tracking_number = '78965413301236547893210'; // Change this to desired one. | |
$ship_date = '07-08-2016'; // Change it to desired one. | |
$order_additional_information['tracking_number'] = $tracking_number;; | |
$order_additional_information['ship_date'] = $ship_date;; | |
return $order_additional_information; | |
} |
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('hf_csv_order_post_role_column', 'hf_csv_order_add_role_column', 10, 2); | |
function hf_csv_order_add_role_column($user_roles=array(), $user_id=NULL) { | |
if ($user_id!==NULL || $user_id===0) { | |
if($user_id===0){ | |
$user_roles = array('role' => 'Guest'); | |
}else{ | |
$user_info = get_userdata($user_id); | |
$roles = implode(', ', $user_info->roles) . " "; | |
$user_roles = array('role' => $roles); |