Skip to content

Commit

Permalink
Merge branch 'feature/module' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Zen4All committed Jan 5, 2020
2 parents a47cf90 + d0772c2 commit 0b8bf79
Show file tree
Hide file tree
Showing 9 changed files with 679 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
$db->Execute("INSERT IGNORE INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, set_function)
VALUES ('Enable Product Compare', 'COMAPRE_STATUS', 'false', 'If true, the Compare buttons will be shown in the shop at the selected pages (depending on the settings below).', " . $configuration_group_id . ", 1, now(), 'zen_cfg_select_option(array(\'true\', \'false\'),'),
('Max Products to Compare', 'COMPARE_PRODUCTS_VALUE_COUNT', '4', 'The number of products to compare at one time.', " . $configuration_group_id . ", 2, now(), ''),
('Max Products to Compare', 'COMPARE_PRODUCTS_DESCRIPTION', '150', 'How many characters max to show of the products description.', " . $configuration_group_id . ", 3, now(), ''),
('Display Product Description', 'COMPARE_PRODUCTS_DESCRIPTION', '150', 'Do you want to display the Product Description?<br /><br />0= OFF<br />150= Suggested Length, or enter the maximum number of characters to display', " . $configuration_group_id . ", 3, now(), ''),
('Enable Product Compare on Product Listing', 'COMAPRE_STATUS_PRODUCT_LISTING', 'false', 'If true, the Compare buttons will be shown on the Product Listing pages.', " . $configuration_group_id . ", 4, now(), 'zen_cfg_select_option(array(\'true\', \'false\'),'),
('Product Compare', 'DEFINE_COMPARE_STATUS', '1', 'Enable the Product Compare Link/Text?<br />0= Link ON, Define Text OFF<br />1= Link ON, Define Text ON<br />2= Link OFF, Define Text ON<br />3= Link OFF, Define Text OFF', '25', '84', now(), 'zen_cfg_select_option(array(\'0\', \'1\', \'2\', \'3\'),');");
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
$db->Execute("INSERT IGNORE INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, set_function)
VALUES ('Enable Product Compare on Product Featured Listing', 'COMPARE_PRODUCTS_FEATURED_STATUS', 'false', 'If true, the Compare buttons will be shown on the Product Featured Listing pages.', " . $configuration_group_id . ", 5, now(), 'zen_cfg_select_option(array(\'true\', \'false\'),'),
('Enable Product Compare on Product New Listing', 'COMPARE_PRODUCTS_NEW_STATUS', 'false', 'If true, the Compare buttons will be shown on the Product New Listing pages.', " . $configuration_group_id . ", 6, now(), 'zen_cfg_select_option(array(\'true\', \'false\'),'),
('Enable Product Compare on Product All Listing', 'COMPARE_PRODUCTS_ALL_STATUS', 'false', 'If true, the Compare buttons will be shown on the Product All Listing pages.', " . $configuration_group_id . ", 7, now(), 'zen_cfg_select_option(array(\'true\', \'false\'),');");
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function addProduct() {
}
$result = $this->getProducts($_SESSION['compareProducts']);

$button = '<button type="button" id="buttonCompareSelectProductId_' . $selected . '" onclick="compare(\'' . $selected . '\',\'removeProduct\')"><i class="fa fa-minus"></i> ' . COMPARE_DEFAULT . '</button>';
$button = '<button type="button" id="buttonCompareSelectProductId_' . $selected . '" onclick="compare(\'' . $selected . '\',\'removeProduct\');"><i class="fa fa-minus"></i> ' . COMPARE_DEFAULT . '</button>';

return([
'data' => $result,
Expand All @@ -67,7 +67,7 @@ public function removeProduct() {
$_SESSION['compareProducts'] = '';
}

$button = '<button type="button" id="buttonCompareSelectProductId_' . $selected . '" onclick="compare(\'' . $selected . '\',\'addProduct\')"><i class="fa fa-plus"></i> ' . COMPARE_DEFAULT . '</button>';
$button = '<button type="button" id="buttonCompareSelectProductId_' . $selected . '" onclick="compare(\'' . $selected . '\',\'addProduct\');"><i class="fa fa-plus"></i> ' . COMPARE_DEFAULT . '</button>';

$result = $this->getProducts($_SESSION['compareProducts']);
return([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,23 @@ class CompareProductsObserver extends base {

public function __construct()
{
if ((defined('COMPARE_PRODUCTS_STATUS') && COMPARE_PRODUCTS_STATUS == 'true') && (defined('COMPARE_PRODUCTS_LIST_STATUS') && COMPARE_PRODUCTS_LIST_STATUS == 'true')) {
$this->attach($this, array('NOTIFY_PRODUCT_LISTING_END'));
if (defined('COMPARE_PRODUCTS_STATUS') && COMPARE_PRODUCTS_STATUS == 'true') {
if (defined('COMPARE_PRODUCTS_LIST_STATUS') && COMPARE_PRODUCTS_LIST_STATUS == 'true') {
$this->attach($this, array('NOTIFY_PRODUCT_LISTING_END'));
}
if (defined('COMPARE_PRODUCTS_FEATURED_STATUS') && COMPARE_PRODUCTS_FEATURED_STATUS == 'true') {
$this->attach($this, array('NOTIFY_PRODUCTS_FEATURED_END'));
}
if (defined('COMPARE_PRODUCTS_NEW_STATUS') && COMPARE_PRODUCTS_NEW_STATUS == 'true') {
$this->attach($this, array('NOTIFY_PRODUCTS_NEW_END'));
}
if (defined('COMPARE_PRODUCTS_ALL_STATUS') && COMPARE_PRODUCTS_ALL_STATUS == 'true') {
$this->attach($this, array('NOTIFY_PRODUCTS_ALL_END'));
}
}
}

public function update(&$class, $eventID, $p1, &$list_box_contents, &$p3, &$p4, &$p5, &$p6, &$p7)
public function update(&$class, $eventID, $p1, &$p2, &$p3, &$p4, &$p5, &$p6, &$p7)
{
switch ($eventID) {
case 'NOTIFY_PRODUCT_LISTING_END':
Expand All @@ -24,13 +35,20 @@ public function update(&$class, $eventID, $p1, &$list_box_contents, &$p3, &$p4,
foreach ($listing as $item) {
$rows++;
$lc_align = '';
$lc_text = '<div id="compareSelectProductId_' . $item['products_id'] . '" class="compareSelect list-compare"><button type="button" id="buttonCompareSelectProductId_' . $item['products_id'] . '" onclick="compare(\'' . $item['products_id'] . '\',\'addProduct\')"><i class="fa fa-plus"></i> ' . COMPARE_DEFAULT . '</button></div>';
$list_box_contents[$rows][] = array('align' => $lc_align,
$lc_text = '<div id="compareSelectProductId_' . $item['products_id'] . '" class="compareSelect list-compare"><button type="button" id="buttonCompareSelectProductId_' . $item['products_id'] . '" onclick="compare(\'' . $item['products_id'] . '\',\'addProduct\');"><i class="fa fa-plus"></i> ' . COMPARE_DEFAULT . '</button></div>';
$p2[$rows][] = array('align' => $lc_align,
'params' => 'class="productListing-data"',
'text' => $lc_text);
}
break;
case 'NOTIFY_PRODUCTS_FEATURED_END':
case 'NOTIFY_PRODUCTS_NEW_END':
case 'NOTIFY_PRODUCTS_ALL_END':

echo '<div id="compareSelectProductId_' . $p1->fields['products_id'] . '" class="compareSelect list-compare">';
echo '<button type="button" id="buttonCompareSelectProductId_' . $p1->fields['products_id'] . '" onclick="compare(\'' . $p1->fields['products_id'] . '\', \'addProduct\');"><i class="fa fa-plus"></i> ' . COMPARE_DEFAULT . '</button>';
echo '</div>';
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function compare(productId, action) {
WHERE p.products_id = " . (int)$value);
?>
compareResultDiv += ' <div class="compareAdded">' + "\n";
compareResultDiv += ' <a href="<?php echo zen_href_link(zen_get_info_page($product_comp_image->fields['products_id']), 'cPath=' . (zen_get_generated_category_path_rev($product_comp_image->fields['master_categories_id'])) . '&products_id=' . $product_comp_image->fields['products_id']); ?>"><?php echo zen_image(DIR_WS_IMAGES . $product_comp_image->fields['products_image'], $product_comp_image->fields['products_name'], '', '35', 'class="listingProductImage"'); ?></a>' + "\n";
compareResultDiv += ' <a href="<?php echo zen_href_link(zen_get_info_page($product_comp_image->fields['products_id']), 'cPath=' . (zen_get_generated_category_path_rev($product_comp_image->fields['master_categories_id'])) . '&products_id=' . $product_comp_image->fields['products_id']); ?>"><?php echo zen_image(DIR_WS_IMAGES . $product_comp_image->fields['products_image'], addslashes($product_comp_image->fields['products_name']), '', '35', 'class="listingProductImage"'); ?></a>' + "\n";
compareResultDiv += ' <div>' + "\n";
compareResultDiv += ' <button type="button" onclick="compare(\'<?php echo $product_comp_image->fields['products_id']; ?>\', \'removeProduct\');" title="remove" class="btn btn-default btn-xs"> <?php echo COMPARE_REMOVE; ?></button>' + "\n";
compareResultDiv += ' </div>' + "\n";
Expand All @@ -43,9 +43,7 @@ function compare(productId, action) {

$(document).ready(function () {
$('#filter-wrapper').after(compareResultDiv);
});

$(document).ready(function () {
let javascriptCompareProductsArray = '';
<?php
if (isset($_SESSION['compareProducts']) && $_SESSION['compareProducts'] != '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@

<?php
if (!empty($_SESSION['compareProducts'])) {
$compName = '';
$compImage = '';
$compDescription = '';
$compModel = '';
$compWeight = '';
$compQuantity = '';
$compPrice = '';
$compManufacturer = '';
$compRemove = '';
// create our table rows of data
foreach ($compareResult as $item) {

Expand Down
Loading

0 comments on commit 0b8bf79

Please sign in to comment.