Created
September 14, 2016 11:35
-
-
Save amin3d/e29af4a492a3faa728b3b52ee155ef69 to your computer and use it in GitHub Desktop.
Iranian Tax Rate woocommerce
This file contains hidden or 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
function add_iranian_tax_rate( $settings ) { | |
$updated_settings = array(); | |
foreach ( $settings as $section ) { | |
if ( isset( $section['id'] ) && 'tax_options' == $section['id'] && | |
isset( $section['type'] ) && 'sectionend' == $section['type'] ) { | |
$updated_settings[] = array( | |
'name' => 'میزان نرخ مالیات', | |
'desc_tip' => 'در این بخش می توانید نرخ مالیات را وارد نمایید', | |
'id' => 'woocommerce_iranian_tax_rate', | |
'type' => 'text', | |
'css' => 'min-width:300px;', | |
'std' => '9', // WC < 2.0 | |
'default' => '9', // WC >= 2.0 | |
'desc' => 'در این بخش می توانید نرخ مالیات را وارد نمایید', | |
); | |
} | |
$updated_settings[] = $section; | |
} | |
return $updated_settings; | |
} | |
add_action('woocommerce_review_order_after_cart_contents','show_iranian_tax_rate_in_checkout'); | |
function show_iranian_tax_rate_in_checkout(){ | |
$total = WC()->cart->cart_contents_total; | |
$rate = get_option('woocommerce_iranian_tax_rate',true); | |
$tax= number_format(($total*$rate)/100); | |
echo '<tr><th>میزان مالیات</th><th>'.$tax.' تومان</th>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment