Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active July 16, 2024 13:01
Show Gist options
  • Save braddalton/9caea45fbfe91b9416e954cc64494b48 to your computer and use it in GitHub Desktop.
Save braddalton/9caea45fbfe91b9416e954cc64494b48 to your computer and use it in GitHub Desktop.
add_action( 'woocommerce_single_product_summary', 'display_discount_table', 20 );
function display_discount_table() {
global $product;
if ( ! $product->is_type( 'simple' ) ) {
return;
}
$discounts = [
5 => '5%',
10 => '10%',
25 => '15%',
50 => '20%',
100 => '25%',
250 => '27%',
500 => '29%'
];
echo '<table class="discount-table">';
echo '<thead><tr><th>Quantity</th><th>Discount</th></tr></thead>';
echo '<tbody>';
foreach ( $discounts as $quantity => $discount ) {
echo '<tr><td>' . $quantity . '</td><td>' . $discount . '</td></tr>';
}
echo '</tbody>';
echo '</table>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment