-
-
Save greguly/7212457 to your computer and use it in GitHub Desktop.
add_filter( 'woocommerce_get_price_html', 'omniwp_credit_dollars_price', 10, 2 ); | |
function omniwp_credit_dollars_price( $price, $product ) { | |
$pricing_rule_sets = get_post_meta( $product->post->ID, '_pricing_rules', true ); | |
$pricing_rule_sets = array_shift( $pricing_rule_sets ); | |
if ( $pricing_rule_sets | |
&& is_array( $pricing_rule_sets ) | |
&& sizeof( $pricing_rule_sets ) ) { | |
ob_start(); | |
?> | |
<table> | |
<thead> | |
<tr> | |
<th><?php _e('Quantity', 'omniwp_core_functionality' ) ?></th> | |
<th><?php _e('Price', 'omniwp_core_functionality' ) ?></th> | |
</tr> | |
</thead> | |
<?php | |
foreach ( $pricing_rule_sets['rules'] as $key => $value ) { | |
if ( '*' == $pricing_rule_sets['rules'][$key]['to'] ) { | |
?> | |
<tr> | |
<td><?php printf( __( '%s units or more', 'omniwp_core_functionality' ) , $pricing_rule_sets['rules'][$key]['from'] ) ?></td> | |
<td><?php echo woocommerce_price( $pricing_rule_sets['rules'][$key]['amount'] ); ?></td> | |
</tr> | |
<?php | |
} else { | |
?> | |
<tr> | |
<td><?php printf( __( 'From %s to %s units', 'omniwp_core_functionality' ) , $pricing_rule_sets['rules'][$key]['from'], $pricing_rule_sets['rules'][$key]['to'] ) ?></td> | |
<td><?php echo woocommerce_price( $pricing_rule_sets['rules'][$key]['amount'] ); ?></td> | |
</tr> | |
<?php | |
} | |
} | |
?> | |
</table> | |
<?php | |
$price = ob_get_clean(); | |
} | |
return $price; | |
} | |
?> |
@greguly
I tried your code and found 2 issues.
- This does not work with percentage % discount set in dynamic pricing
- This make variable product's pricing show an warning/error. (I have different prices for different variations. )
Can you take a look? Thanks!
Hi!
We use commas for decimal seperators, but this plugin wont accept that, and only shows 00 (zeros) as decimals, even though other number should be there. What do i do?
Hi,
i used your code and it's work, but when the interval date of the dynamic price rule is over, I would not show the table. It’s possible?
Thank you
Thx for this! Quick question : the provided code also forces showing the table on the product catalogue page - how can we keep the table showing on single product page only? Thank you!!
@pamolade for decimals correct, i change on line 235 to:
case 'fixed_price':
$output .= '' . sprintf( $pricing_rule_sets['rules'][$key]['amount'] ) . __( ' Per item', 'woocommerce-dynamic-pricing-table' ) . '';
break;
Hiya,
I am amazed that this piece of code was used by others.
Where do you see line 235 @senoux?
Cheers,
Gabriel
Hello,
I'm using this code:
add_filter( 'init', 'wc_tax_exempt_user_roles' );
function wc_tax_exempt_user_roles() {
if ( ! is_admin() ) {
global $woocommerce;
if ( current_user_can('wholesale') ) {
$woocommerce->customer->set_is_vat_exempt(true);
} else {
$woocommerce->customer->set_is_vat_exempt(false);
}
}
}
to disable taxes for wholesale buyers - this is how it works in EU.
And using Dynamic Pricing, prices in catalog are always displayed with tax (using 0rules). Do you know how to fix it?
Thanks