Created
November 9, 2018 11:08
-
-
Save AshlinRejo/26b88108072d70a46b58b03a5c29965e to your computer and use it in GitHub Desktop.
Woo discount rules: Buy x and get % discount - template override
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
<?php | |
/** | |
* List matched Rules in Table format | |
* | |
* This template can be overridden by copying it to yourtheme/plugin-folder-name/discount-table.php | |
*/ | |
if (!defined('ABSPATH')) exit; // Exit if accessed directly | |
if (!isset($table_data) || empty($table_data)) return false; | |
$base_config = (is_string($data)) ? json_decode($data, true) : (is_array($data) ? $data : array()); | |
$show_discount_title_table = isset($base_config['show_discount_title_table'])? $base_config['show_discount_title_table']: 'show'; | |
$show_column_range_table = isset($base_config['show_column_range_table'])? $base_config['show_column_range_table']: 'show'; | |
$show_column_discount_table = isset($base_config['show_column_discount_table'])? $base_config['show_column_discount_table']: 'show'; | |
?> | |
<table class="woo_discount_rules_table"> | |
<tbody> | |
<?php | |
$have_discount = false; | |
$table = $table_data; | |
foreach ($table as $index => $item) { | |
if ($item) { | |
foreach ($item as $id => $value) { | |
?> | |
<tr class="wdr_tr_body"> | |
<?php if ($show_discount_title_table == 'show') { ?> | |
<td class="wdr_td_body_title">Buy <?php echo $value->min_qty; ?> and get <?php echo $table_data_content[$index.$id]['discount']; ?> as discount</td> | |
<?php } ?> | |
</tr> | |
<?php } | |
$have_discount = true; | |
} | |
} | |
if (!$have_discount) { | |
?> | |
<tr class="wdr_tr_body_no_discount"> | |
<td> | |
<?php esc_html_e('No Active Discounts.', 'woo-discount-rules'); ?> | |
</td> | |
</tr> | |
<?php | |
} | |
?> | |
</tbody> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment