Support » Plugin: WooCommerce » change tax rate diff items

  • Resolved atpdev

    (@atpdev)


    Hi.
    I need to change the rate of several different products to other shipments.

    Example:
    1 Backpack = $15 + $10 (tax)
    1 Mouse = $5 + $12 (tax)
    1 Keyboard = $8 + $14 (tax)

    My products are all with ID, I have 1 purchase of a backpack, so the shipment is equivalent to where it is sent which is $city and the product $product_id to vary the final price.

    code:

    //Prueba
    	} else if ($state == 'LMA' && in_array($distrito, ['Carabayllo','Chaclacayo','Cieneguilla','San Juan de Lurigancho','Lurín','Pachacamac','Pachacutec','Playas Sur','Pucusana','Punta Hermosa','Punta Negra','San Bartolo','Santa María del Mar','Santa Rosa']) && $product_id = 6721)) {
    	 $rates['flat_rate:7']->cost += 7.4;
    	 $rates['flat_rate:7']->label = 'De 2 a 3 dias hábiles de 9am a 7pm';
    //Fin Prueba

    ID Product = 6721 = Office chair tax (cost += 7.4) other items normal tax (cost += 3)

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support AW a11n

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there!

    I don’t think I fully understand what you’re trying to do.

    You mention different tax rates for items ( WooCommerce can handle a standard tax rate and a reduced rate, but not more than that with customization), but then the code you sent looks to be shipping rate code.

    What exactly are you trying to change? Any more info you can share about what you are trying to do will help us advise better.

    Thread Starter atpdev

    (@atpdev)

    thanks for the reply, but I have already managed to solve this.

    Code Solved:

    foreach( $package['contents'] as $cart_item ) {
    			if ( in_array( $cart_item['product_id'], $product_ids ) ){
    				// Si están en el carrito el precio del envío cambia a -> 19:50
    				$rates['flat_rate:7']->cost += 12; // 19.50
    				$rates['flat_rate:7']->label = 'De 2 a 3 dias hábiles de 9am a 7pm';
    			} else {
    				// Si no hay sillas en el carrito el precio del envío queda en 12.90
    				$rates['flat_rate:7']->cost += 5.4; // 12.90
    				$rates['flat_rate:7']->label = 'De 2 a 3 dias hábiles de 9am a 7pm';
    			}
    		}
    Plugin Support Mirko P.

    (@rainfallnixfig)

    Hi @atpdev,

    Glad to hear you’ve been able to solve this.

    I’m going to mark the thread as resolved but feel free to start a new topic if you have any more questions!

    Cheers.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.