Index: install/english.lang
===================================================================
--- install/english.lang (revision 15041)
+++ install/english.lang (working copy)
@@ -127,6 +127,7 @@
T3JkZXIgQ29udGVudHM=
U2hpcHBpbmcgJiBCaWxsaW5nIEluZm9ybWF0aW9u
VGltZWZyYW1l
+ TWF4aW1hbCBudW1iZXIgb2YgcHJvZHVjdHMgaW4gY29tcGFyaXNvbiBsaXN0
VGF4ZXMgaW5jbHVkZWQgaW4gcHJvZHVjdCBwcmljZSwgc2hpcHBpbmcgY29zdCAmIHByb2Nlc3NpbmcgZmVl
U2hvdyBQcm9kdWN0IEltYWdlcyBpbiBPcmRlcnM=
TnVtYmVyIG9mIGRheXMgZm9yIGEgcHJvZHVjdCB0byBiZSBOZXc=
Index: install/install_data.sql
===================================================================
--- install/install_data.sql (revision 15041)
+++ install/install_data.sql (working copy)
@@ -53,6 +53,7 @@
INSERT INTO SystemSettings VALUES(DEFAULT, 'product_RatingDelay_Value', '30', 'In-Commerce', 'in-commerce:output', 'la_Text_Products', 'la_prompt_DupRating', 'text', '', 'style="width: 50px;"', 10.1, 1, 1, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'product_RatingDelay_Interval', '86400', 'In-Commerce', 'in-commerce:output', 'la_Text_Products', 'la_prompt_DupRating', 'select', '', '1=la_opt_Sec||60=la_opt_Min||3600=la_opt_Hour||86400=la_opt_Day||604800=la_opt_Week||2419200=la_opt_Month||29030400=la_opt_Year', 10.1, 2, 1, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'ShowProductImagesInOrders', '0', 'In-Commerce', 'in-commerce:output', 'la_Text_Products', 'la_config_ShowProductImagesInOrders', 'checkbox', NULL, NULL, 10.11, 0, 1, NULL);
+INSERT INTO SystemSettings VALUES(DEFAULT, 'MaxCompareProducts', '3', 'In-Commerce', 'in-commerce:output', 'la_Text_Products', 'la_config_MaxCompareProducts', 'text', NULL, NULL, 10.12, 0, 1, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'Comm_Perpage_Reviews', '10', 'In-Commerce', 'in-commerce:output', 'la_Text_Reviews', 'la_config_PerpageReviews', 'text', NULL, NULL, 20.01, 0, 1, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'product_ReviewDelay_Value', '30', 'In-Commerce', 'in-commerce:output', 'la_Text_Reviews', 'la_prompt_DupReviews', 'text', '', 'style="width: 50px;"', 20.02, 1, 1, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'product_ReviewDelay_Interval', '86400', 'In-Commerce', 'in-commerce:output', 'la_Text_Reviews', 'la_prompt_DupReviews', 'select', '', '1=la_opt_Sec||60=la_opt_Min||3600=la_opt_Hour||86400=la_opt_Day||604800=la_opt_Week||2419200=la_opt_Month||29030400=la_opt_Year', 20.02, 2, 1, NULL);
Index: install/upgrades.sql
===================================================================
--- install/upgrades.sql (revision 15041)
+++ install/upgrades.sql (working copy)
@@ -257,3 +257,5 @@
'Comm_Order_Number_Format_S', 'Comm_RecurringChargeInverval', 'Comm_AutoProcessRecurringOrders', 'MaxAddresses',
'Comm_MaskProcessedCreditCards', 'OrderVATIncluded'
);
+
+INSERT INTO SystemSettings VALUES(DEFAULT, 'MaxCompareProducts', '3', 'In-Commerce', 'in-commerce:output', 'la_Text_Products', 'la_config_MaxCompareProducts', 'text', NULL, NULL, 10.12, 0, 1, NULL);
Index: units/products/products_event_handler.php
===================================================================
--- units/products/products_event_handler.php (revision 15041)
+++ units/products/products_event_handler.php (working copy)
@@ -538,17 +538,25 @@
// recent products: end
// compare products: begin
- $compare_products = $this->getCompareProducts();
- if ( $compare_products ) {
- $compare_products = $this->Conn->qstrArray($compare_products);
- $type_clauses['compare']['include'] = '%1$s.ProductId IN (' . implode(',', $compare_products) . ') AND PrimaryCat = 1';
- $type_clauses['compare']['except'] = '%1$s.ProductId NOT IN (' . implode(',', $compare_products) . ') AND PrimaryCat = 1';
+ if ( in_array('compare', $types) || in_array('compare', $except_types) ) {
+ $compare_products = $this->getCompareProducts();
+
+ if ( $compare_products ) {
+ $compare_products = $this->Conn->qstrArray($compare_products);
+ $type_clauses['compare']['include'] = '%1$s.ProductId IN (' . implode(',', $compare_products) . ') AND PrimaryCat = 1';
+ $type_clauses['compare']['except'] = '%1$s.ProductId NOT IN (' . implode(',', $compare_products) . ') AND PrimaryCat = 1';
+ }
+ else {
+ $type_clauses['compare']['include'] = '0';
+ $type_clauses['compare']['except'] = '1';
+ }
+
+ $type_clauses['compare']['having_filter'] = false;
+
+ if ( $event->getEventParam('per_page') === false ) {
+ $event->setEventParam('per_page', $this->Application->ConfigValue('MaxCompareProducts'));
+ }
}
- else {
- $type_clauses['compare']['include'] = '0';
- $type_clauses['compare']['except'] = '1';
- }
- $type_clauses['compare']['having_filter'] = false;
// compare products: end
// products already in shopping cart: begin
@@ -1482,13 +1490,23 @@
protected function OnAddToCompare(kEvent &$event)
{
$products = $this->getCompareProducts();
-
$product_id = (int)$this->Application->GetVar($event->Prefix . '_id');
if ( $product_id ) {
- $products[] = $product_id;
- $this->Application->Session->SetCookie('compare_products', implode('|', array_unique($products)));
+ $max_products = $this->Application->ConfigValue('MaxCompareProducts');
+
+ if ( count($products) < $max_products ) {
+ $products[] = $product_id;
+ $this->Application->Session->SetCookie('compare_products', implode('|', array_unique($products)));
+
+ $event->SetRedirectParam('result', 'added');
+ }
+ else {
+ $event->SetRedirectParam('result', 'error');
+ }
}
+
+ $event->SetRedirectParam('pass', 'm,p');
}
/**
@@ -1507,7 +1525,11 @@
if ( $product_id && in_array($product_id, $products) ) {
$products = array_diff($products, Array ($product_id));
$this->Application->Session->SetCookie('compare_products', implode('|', array_unique($products)));
+
+ $event->SetRedirectParam('result', 'removed');
}
+
+ $event->SetRedirectParam('pass', 'm,p');
}
/**