wiltscomputers
Forum Replies Created
-
Thank you both so much for the revised and improved code with explanations! It makes perfect sense now when I can see what you have done and is exactly what I need!
Thanks to the above code example I have managed to modify it slightly to suit my needs, but I’m still struggling with one part – I’d like to expand the criteria not only to disable tax for DHL Express but for other shipping services. The code below works perfectly for ‘dhlexpress_WPX’ but I can’t seem to use an OR function to disable VAT for other shipping services.
I’m sure it’s not impossible, but I would appreciate if someone could point me in the right direction. Thank you!
// If customer selects DHL Express and in country is in the list below, this disables the VAT at checkout
add_action( 'woocommerce_checkout_update_order_review', 'disable_tax_for_us_dhlexpress' );
function disable_tax_for_us_dhlexpress( $post_data ) {
parse_str( $post_data, $output );
// Make sure shipping country and shipping method are set
if (
isset( $output['shipping_country'], $output['shipping_method'] ) &&
($output['shipping_country'] === 'US' or $output['shipping_country'] === 'FR' or $output['shipping_country'] === 'DE' or $output['shipping_country'] === 'IE' or $output['shipping_country'] === 'NL' or $output['shipping_country'] === 'CY' or $output['shipping_country'] === 'MT' or $output['shipping_country'] === 'AT' or $output['shipping_country'] === 'CH' or $output['shipping_country'] === 'LU' or $output['shipping_country'] === 'NO' or $output['shipping_country'] === 'SE') &&
in_array ( 'dhlexpress_WPX', (array) $output['shipping_method'], true )
) {
WC()->customer->set_is_vat_exempt( true );
} else {
WC()->customer->set_is_vat_exempt( false );
}
}Thanks – it’s all sorted now with help from Woocommerce
That works perfectly – many thanks, you saved me from hours of headaches!!
Thanks – I’ll try that…
Thanks but this isn’t specific to a plugin – it should work with any shipping method
// Selects DHL Express and country GB to disable VAT
add_action('woocommerce_review_order_before_shipping', 'my_custom_action_based_on_shipping_method');
function my_custom_action_based_on_shipping_method($post_data) {
// Get the chosen shipping method ID from the session
$chosen_shipping_method = WC()->session->get('chosen_shipping_methods');
// Check if a method is chosen and if it's the one you're looking for
if (!empty($chosen_shipping_method) && $chosen_shipping_method[0] === 'dhlexpress_DOM' ) {
// Do something specific, e.g., add a custom message, apply a discount, etc.
echo '<p>You have selected DHL Express</p>';
add_action( 'woocommerce_checkout_update_order_review', 'removal_tax' );
function removal_tax( $post_data ) {
WC()->customer->set_is_vat_exempt( false );
parse_str( $post_data, $output );
if ( $output['shipping_country'] === 'GB' ) WC()->customer->set_is_vat_exempt( true );
}
}
}- This reply was modified 9 months, 1 week ago by wiltscomputers.
Many thanks for the reply. I wasn’t sure what the ^ refers to though?
I tried this code –
#tripetto-runner-c418265d iframe { right: 50px !important; }
“tripetto-runner-c418265d” is my DIV ID but nothing changes…
Am I missing something?
Thanks!
Forum: Reviews
In reply to: [WooCommerce PayPal Payments] PoorI think I tried all of them but couldn’t resolve the initial problem where Woocommerce would send the SKU to Paypal as ‘order notes’
I am now using the standard version which comes with Woocommerce – it seems to be the most simple and reliable. The others seem to only add things to the front end configuration such as fancy buttons which is not what I need. I don’t want to loose sales for the sake of this sort of improvement.I have now deleted this plugin as there are too many errors occurring. I never did manage to resolve the original issue….
I’m still struggling with this – any help would be very much appreciated… thanks!
Hello Niklas,
Thanks for your reply… This is a screenshot from a Paypal email:
http://wiltscomputers.co.uk/sku.jpg
The ‘SKU’ is renamed to ‘Item No’
I wasn’t sure how to modify the API to not show something, and couldn’t find anything in the original code relating to SKU to delete or modify it.
Thank you
Yes – version 1.0.4 works fine – I’ll leave it installed for now and try not update automatically….
Since yesterday I am not receiving the GTIN in the emails for new orders. It appears that it is also missing from the order itself so not being added as an order item meta.
I have checked the box is ticked to save the meta and it is indeed still on the product page. Is there a setting that has been added or deleted that I am missing?