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_checkout_change_required_fields_to_optional' ); | |
function xa_checkout_change_required_fields_to_optional( $fields ) { | |
$fields['billing']['billing_address_1']['required'] = false; | |
$fields['billing']['billing_address_2']['required'] = false; | |
$fields['billing']['billing_postcode']['required'] = false; | |
$fields['billing']['billing_city']['required'] = false; | |
$fields['billing']['billing_phone']['required'] = false; | |
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_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_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
function alter_ups_order_xml_export_data( $order_details ) { | |
foreach ($order_details as $key => $value) { | |
$order_details[$key]['Shipment']['ShipFrom']['UPSAccountNumber'] = 'xxxxxx'; // UPS Account Number | |
$order_details[$key]['Shipment']['ShipmentInformation']['ServiceType'] = 'GND'; // UPS ServiceType | |
$orderID = $order_details[$key]['Shipment']['ShipmentKey']; | |
$order = new WC_Order($orderID); | |
$coupons_list = ' CouponCode:'; | |
foreach( $order->get_used_coupons() as $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
add_filter('woocommerce_package_rates', 'wf_remove_shipping_options_for_particular_country', 10, 2); | |
function wf_remove_shipping_options_for_particular_country($available_shipping_methods, $package){ | |
global $woocommerce; | |
$country_list = array( | |
'CA' => 'wf_dhl_shipping', | |
'US' => 'wf_dhl_shipping', | |
); | |
$customer_country = $woocommerce->customer->get_shipping_country(); |
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
//code snippet to replace meta key with value | |
add_filter('wf_pklist_modify_meta_data', 'wf_pklist_change_meta_data_label', 1); | |
function wf_pklist_change_meta_data_label($meta_data) | |
{ | |
//replace the array key value with your custom key value. | |
$label_array = array( | |
'_wcj_product_input_fields_local_1' => 'Global Desc', | |
'_wcj_product_input_fields_global_1' => 'Local Desc' | |
); |
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_order_product_title', 'xa_product_dimension_add_func',99,2); | |
function xa_product_dimension_add_func($item_name ='', $product ='') | |
{ | |
if(!empty($product)) | |
{ | |
return $item_name . ' <small>( '.wc_format_dimensions($product->get_dimensions(false)).' )</small>'; | |
}else | |
{ | |
return $item_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
add_filter('woocommerce_order_product_title_for_pk_list', 'xa_product_dimension_add_func',99,2); | |
function xa_product_dimension_add_func($item_name ='', $product ='') | |
{ | |
if(!empty($product)) | |
{ | |
return $item_name . ' <small>( '.wc_format_dimensions($product->get_dimensions(false)).' )</small>'; | |
}else | |
{ | |
return $item_name; |
OlderNewer