• Resolved maryoli

    (@maryoli)


    Hello,

    I’m using the wcmp and your module, I want to remove taxes from the orders ordered by clients that has a certain usermeta with a value.

    My codes worked for the frontend order page and the admin order page but not on the sub-order created by the vendor module.

    How can I remove taxes programatically from the vendor order, and hae it shown in the vendor admin panel and the email he recieves after the order is created.

    Best regards.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author MultiVendorX

    (@wcmp)

    Hi @maryoli, can you share the code you ar using for the main order, so we can check and assist with with the sub order too.

    Thread Starter maryoli

    (@maryoli)

    Hello,

    This is the code that works for the main order :

    function flat_rates_cost( $rates, $package ) {
    
        $user = wp_get_current_user();
        $data = get_user_meta( $user->ID, 'dispense_tva', true );
             
        if($data=='oui'){
    		foreach ( $rates as $rate_key => $rate ){
    			//if ( 'free_shipping' !== $rate->method_id ) {
    				$has_taxes = false;
    				$taxes = [];
    	 
    				// Taxes rate cost (if enabled)
    				foreach ($rates[$rate_key]->taxes as $key => $tax){
    					if( $tax > 0 ){
    						$has_taxes = true;
    						$taxes[$key] = 0; // Set to 0 (zero)
    					}
    				}
    				if( $has_taxes )
    					$rates[$rate_key]->taxes = 0;
    			//}
    		}
    	}
        return $rates;
    }
    add_filter( 'woocommerce_package_rates', 'flat_rates_cost', 10, 2 );

    Best regards.

    Thread Starter maryoli

    (@maryoli)

    hello @wcmp ,

    Any updates on the matter ?

    I tried some functionsn but still not working on the sub-order.

    Best regards.

    Plugin Author MultiVendorX

    (@wcmp)

    Hi @maryoli, thanks for the code.

    But to be honest, looking at the code we are not quite sure about the flow, that you are getting.
    Can you share a video of the flow, so we can check and assist you further.

    Thread Starter maryoli

    (@maryoli)

    Hello @wcmp ,

    I just have normal woocommerce orders, if the logged in user has the metadata ‘dispense_tva’ equals ‘oui’ I have to remove all taxes from the current order he is passing.

    Using the code I sent above, what I have is :

    On the front page the prices on the cart and order page is shown without taxes and VAT total is not shown and the order shown on the admin panel of the main order + the email sent to the client don’t include VAT and taxes which is correct, but on the admin panel of the vendor + the email sent to the vendor I still have the VAT total showing and the total price of the order containes the total of the order + the total of the VAT.

    What I’m looking for now is to remove the VAT from the sub-order on the vendor admin panel and the email sent to the vendor.

    Example of an order :

    main order : https://snipboard.io/9xzd8m.jpg

    sub-order created for the vendor : https://snipboard.io/6KYOv4.jpg

    Best regards.

    Plugin Author MultiVendorX

    (@wcmp)

    @maryoli, in case of suborder we are fetching the same items as in parent order. so the code you have added to remove vat, in order to apply the same for sub order too, you need to do additional coding.

    So, you have to identify suborder by checking wp_get_post_parent_id( $post->ID ) and you can find all suborder or a parent order by using get_mvx_suborders. Then apply the same logic here too.

    You can check more about our codes on here https://github.com/multivendorx/MultiVendorX/blob/main/classes/class-mvx-order.php.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘set taxes to 0 for clients with specific user metas for vendor orders’ is closed to new replies.