View Download File
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 | |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
// $file = sanitize_file_name( $_GET['path'] ); | |
// sanitize path | |
$file = realpath( $_GET['path'] ); | |
// echo $file; | |
if ( current_user_can( 'edit_shop_orders' ) && check_admin_referer( 'download-dhl-label' ) ) { |
View gist:d1c32e93dad8008dddd9151b69e0994c
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', 'remove_phone_number', 10, 2); | |
function remove_phone_number($args, $order_id) { | |
if(isset($args['shipping_address']['phone'])){ | |
unset($args['shipping_address']['phone']); | |
} | |
return $args; | |
} |
View gist:6751305c06a852b972247af0e595d145
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) { | |
$total_weight += 1; // Add any weight needed, units of measure will be whatever is set in WooCommerce | |
return $total_weight; | |
} |
View gist:a7bc62eb3dc50145fcd331023c022cf5
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', 'remove_email_number', 10, 2); | |
function remove_email_number($args, $order_id) { | |
if(isset($args['shipping_address']['email'])){ | |
unset($args['shipping_address']['email']); | |
} | |
return $args; | |
} |
View gist:669913cad84edaea25bfaf415f44a956
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', 'custom_shipping_address_no', 10, 2); | |
function custom_shipping_address_no($args, $order_id) { | |
$args['shipping_address']['address_2'] = get_post_meta($order_id, 'my_custom_address_no', true); // Set to your custom address number field, most likely a order meta data | |
return $args; | |
} |
View Add or Update Post Number
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_post_number', 10, 2); | |
function modify_post_number($args, $order_id) { | |
if( $order_id == 12345 ){ | |
$args['shipping_address']['dhl_postnum'] = 54321; | |
} | |
return $args; | |
} |
View Modify base 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('pr_shipping_dhl_base_country', 'my_custom_base_country'); | |
function my_custom_base_country( $base_country ) { | |
return 'DE'; | |
} |
View Modify Free Products
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( $item_value['item_value'] == 0 ) { | |
$args['items'][ $item_key ]['item_value'] = 0.01; | |
} | |
} | |
} | |
return $args; |
View Ensure Item Price 2 Decimal Float
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; |
View Change SKU argument to 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_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; | |
} | |
} |
OlderNewer