• Resolved talk2wowels

    (@talk2wowels)


    Hi i am using Advanced Order Export For WooCommerce

    in india there is multiple tax slabs and CGST, IGST and SGST i want to export each values seperate column for every order.

    ————————————————————–
    Order ID | Tax State | Tax Percentage | CGST | SGST | IGST
    ————————————————————–
    #2438 | KL | 18% | 9% | 9 % |
    #2439 | TN | 18% | | | 18%
    ————————————————————–

    I want to export the stored values in database using Advanced Order Export For WooCommerce

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author algol.plus

    (@algolplus)

    Hello

    please, add following code to functions.php or use “Code Snippets” plugin.

    You will see new fields in >Setup Fields>Products.

    // Adding CGST SGST IGST in order Export Tax Breakup Advanced Order Export
    class WOE_add_product_shipping_taxes{
    	var $taxes = array("CGST","SGST","IGST");
    	
    	function __construct() {
    		add_filter('woe_get_order_fields', array($this,'add_order_fields'), 10, 1);
    		add_filter('woe_get_order_product_fields', array($this,'add_product_fields'), 10, 2);
    		
    		add_filter('woe_fetch_order', array($this,'fill_shipping_taxes'), 10, 2);
    		add_filter('woe_fetch_order_product',array($this,'fill_product_taxes'), 10, 5);
    	}	
    	
    	function add_order_fields($fields) {
    		global $wpdb;
    		foreach($this->taxes  as $tax) {
    			$fields['shipping_tax_amount_'.$tax] = array('label'=>"Shipping $tax Amount",'checked' => 1, 'segment'=>'cart','colname'=>"Shipping $tax Amount", 'format'=>'money');
    			$fields['shipping_tax_percentage_'.$tax] = array('label'=>"Shipping $tax Percentage",'checked' => 1, 'segment'=>'cart','colname'=>"Shipping $tax Percentage", 'format'=>'number');
    		}	
    		return $fields;
    	}
    	function add_product_fields($fields,$format) {
    		global $wpdb;
    		foreach($this->taxes  as $tax) {
    			$fields['tax_amount_'.$tax] = array('label'=>"Product $tax Amount",'checked' => 1, 'segment'=>'cart','colname'=>"Product $tax Amount", 'format'=>'money');
    			$fields['tax_percentage_'.$tax] = array('label'=>"Product $tax Percentage",'checked' => 1, 'segment'=>'cart','colname'=>"Product $tax Percentage", 'format'=>'number');
    		}	
    		return $fields;
    	}
    	
    	function fill_shipping_taxes($row, $order ) {
    		$shipping_taxes = $shipping_tax_rates = array();
    		$order_taxes = $order->get_taxes();
    		foreach($order->get_items('shipping') as $shipping) {
    			$tax_data = $shipping->get_taxes();
    			foreach($order_taxes as $tax_item) {
    				$tax_item_id    = $tax_item->get_rate_id();
    				$label = $tax_item->get_label() ;
    				if( isset($shipping_taxes[$label]) AND $shipping_taxes[$label]>0)
    				  continue;
    				$shipping_taxes[$label]  = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : 0;
    				$shipping_tax_rates[$label] = $shipping->get_total()>0 ? round($shipping_taxes[$label]/$shipping->get_total() * 100) : 0;
    			}	
    		}
    		
    		foreach($this->taxes  as $tax) {
    			if( isset($row['shipping_tax_amount_'.$tax]) )
    				$row['shipping_tax_amount_'.$tax] = wc_round_tax_total($this->find_tax_by_label($shipping_taxes,$tax));
    			if( isset($row['shipping_tax_percentage_'.$tax]) )
    				$row['shipping_tax_percentage_'.$tax] = $this->find_tax_by_label($shipping_tax_rates,$tax);
    		}	
    		
    		return $row;
    	}
    	
    	function fill_product_taxes($row, $order, $item, $product, $item_meta) { 
    		$product_taxes = $product_tax_rates = array();
    		$order_taxes = $order->get_taxes();
    		
    		$tax_data = $item->get_taxes();
    		foreach($order_taxes as $tax_item) {
    			$tax_item_id    = $tax_item->get_rate_id();
    			$label = $tax_item->get_label() ;
    			if( isset($product_taxes[$label]) AND $product_taxes[$label]>0)
    				  continue;
    			$product_taxes[$label]  = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : 0;
    			$product_tax_rates[$label] = $item->get_total()>0 ? round($product_taxes[$label]/$item->get_total() * 100) : 0;
    		}	
    		
    		foreach($this->taxes  as $tax) {
    			if( isset($row['tax_amount_'.$tax]) )
    				$row['tax_amount_'.$tax] = wc_round_tax_total( $this->find_tax_by_label($product_taxes,$tax));
    			if( isset($row['tax_percentage_'.$tax]) )
    				$row['tax_percentage_'.$tax] = $this->find_tax_by_label($product_tax_rates,$tax);
    		}	
    		return $row;
    	}
    	
    	function find_tax_by_label($taxes,$label) {
    		$value = 0;
    		foreach($taxes as $key=>$v) {
    			if( strpos($key,$label) !== false) {
    				$value = $v;
    				break;
    			}
    		}
    		return $value;
    	}
    }	
    new WOE_add_product_shipping_taxes();
    
    // Adding CGST SGST IGST in order Export Tax Breakup Advanced Order Export End

    Thread Starter talk2wowels

    (@talk2wowels)

    hi, @algolplus

    That really helped!, i checked it in my website, it works

    Thank you for your fast reply ??

    Plugin Author algol.plus

    (@algolplus)

    You’re welcome

    Thread Starter talk2wowels

    (@talk2wowels)

    Hi, one help required. in my website products are inclusive of gst

    Example:
    Product MRP : 1180
    GST : 18% Inclusive

    During Order A Discount Applied
    Applied a discount of : Rs100
    After Discount The PRICE is Rs.1080 (inclusive 18% GST)

    At the time of export i want to get the actual like this (CGST & SGST Case)
    ———————————————————————————
    Price | Discount | Price After Discount | CGST | SGST | IGST
    ———————————————————————————
    1180 | 100 | 1080 | 82.375 | 82.375 |

    At the time of export i want to get the actual like this (IGST Case)
    ———————————————————————————
    Price | Discount | Price After Discount | CGST | SGST | IGST
    ———————————————————————————
    1180 | 100 | 1080 | | | 164.75

    Thanks in Advance

    Plugin Author algol.plus

    (@algolplus)

    Hello

    please, submit these screenshots as new ticket to https://algolplus.freshdesk.com/

    1. your tax settings (>WooCommerce>Settings>Tax)
    2. one order (>WooCommerce>Order>edit order)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Indian Tax Informations Export – by using Advanced Order Export For WooCommerce’ is closed to new replies.