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
// Suppress faire currency matching | |
add_filter('faire_wc_suppress_currency_matching', 'custom_faire_wc_suppress_currency_matching'); | |
function custom_faire_wc_suppress_currency_matching($bool) { | |
return TRUE; | |
} |
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('faire_add_to_order_product', 'faire_product_price_zero'); | |
function faire_product_price_zero( $product ) { | |
$product['item']->price_cents = 0; | |
return $product; | |
} |
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
// Override DHL Label Export Type, and return "Sale of goods" | |
add_filter( 'pr_shipping_dhl_paket_label_shipment_export_type' , 'custom_dhl_export_type', 10, 1 ); | |
function custom_dhl_export_type($type) { | |
return 'COMMERCIAL_GOODS'; | |
} |
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('pr_shipping_dhl_label_args', 'modify_item_sku', 10, 2); | |
function modify_item_sku($args, $order_id) { | |
if( isset( $args['items'] ) ) { | |
foreach ($args['items'] as $item_key => $item_value) { | |
$item_value['item_description'] = "ENTER THE DESCRIPTION YOU WANT"; | |
} | |
} | |
return $args; | |
} |
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('pr_shipping_dhl_label_args', 'maybe_add_company', 10, 2); | |
function maybe_add_company($args, $order_id) { | |
if( ! empty( $args['shipping_address']['company'] ) ) { | |
if( ! empty( $args['shipping_address']['address_2'] ) ) { | |
$args['shipping_address']['address_2'] = $args['shipping_address']['address_1'] . ', ' . $args['shipping_address']['address_2']; | |
} else { | |
$args['shipping_address']['address_2'] = $args['shipping_address']['address_1']; | |
} | |
$args['shipping_address']['address_1'] = $args['shipping_address']['company']; | |
} |
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('pr_shipping_dhl_label_args', 'maybe_remove_state', 10, 2); | |
function maybe_remove_state($args, $order_id) { | |
if( isset( $args['shipping_address']['state'] ) && ( strlen( $args['shipping_address']['state'] ) < 2 || strlen( $args['shipping_address']['state'] ) > 20 ) ) { | |
unset($args['shipping_address']['state']); | |
} | |
return $args; | |
} |
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('pr_shipping_dhl_order_weight', 'custom_add_weight', 10, 2); | |
function custom_add_weight($total_weight, $order_id) { | |
$order = wc_get_order( $order_id ); | |
if ($order) { | |
$shipping_address = $order->get_address( 'shipping' ); | |
if( $shipping_address['country'] == 'DE' ) { | |
return 30; | |
} | |
} |
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('pr_shipping_dhl_label_args', 'modify_order_id_to_number', 10, 2); | |
function modify_order_id_to_number($args, $order_id) { | |
$order = wc_get_order( $order_id ); | |
$args['dhl_settings']['dhl_label_ref'] = $order->get_order_number(); | |
return $args; | |
} |
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('pr_shipping_dhl_label_args', 'modify_item_sku', 10, 2); | |
function modify_item_sku($args, $order_id) { | |
if( isset( $args['items'] ) ) { | |
foreach ($args['items'] as $item_key => $item_value) { | |
if( isset( $item_value['sku'] ) ) { | |
$product_id = wc_get_product_id_by_sku( $item_value['sku'] ); | |
if( $product_id ) { | |
$args['items'][ $item_key ]['sku'] = $product_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_filter('pr_shipping_dhl_label_args', 'modify_item_price', 10, 2); | |
function modify_item_price($args, $order_id) { | |
if( isset( $args['items'] ) ) { | |
foreach ($args['items'] as $item_key => $item_value) { | |
if( isset( $item_value['item_value'] ) ) { | |
$args['items'][ $item_key ]['item_value'] = round( floatval( $item_value['item_value'] ), 2); | |
} | |
} | |
} | |
return $args; |
NewerOlder