Skip to content

Commit 5e0e085

Browse files
committed
v3.0.5
Prevent discount warnings from displaying when no deals are present.
1 parent 9b2b7de commit 5e0e085

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

app/code/community/PriceWaiter/NYPWidget/Model/Total/Quote.php

+29-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ public function collect(Mage_Sales_Model_Quote_Address $address)
3131
{
3232
parent::collect($address);
3333

34-
if (!$this->shouldCollectAddress($address)) {
34+
$deals = $this->getPriceWaiterDeals();
35+
36+
// shouldCollectAddress adds session notices about discounts
37+
// if we are not eligible due to coupon codes or card discounts
38+
// avoid showing those notices if there are no deals
39+
if (!count($deals)) {
3540
return $this;
3641
}
3742

38-
$deals = $this->getPriceWaiterDeals();
43+
if (!$this->shouldCollectAddress($address)) {
44+
return $this;
45+
}
3946

4047
// In case of collision, favor more recent deals over less recent.
4148
usort($deals, array(__CLASS__, 'sortDealsRecentFirst'));
@@ -433,7 +440,8 @@ protected function shouldCollectAddress(Mage_Sales_Model_Quote_Address $addr)
433440
$quote = $addr->getQuote();
434441

435442
// (1) Don't allow when there is a coupon code
436-
$hasCouponCode = !empty($quote->getCouponCode());
443+
$couponCode = $quote->getCouponCode();
444+
$hasCouponCode = !empty($couponCode);
437445
if ($hasCouponCode) {
438446
Mage::getSingleton('core/session')->addNotice(
439447
'Your offer discount could not be applied because there is a coupon code in use.'
@@ -459,6 +467,24 @@ protected function shouldCollectAddress(Mage_Sales_Model_Quote_Address $addr)
459467
}
460468
}
461469

470+
// (2) Don't allow if the sales rule applies to _more than shipping only_
471+
$ruleIds = $quote->getAppliedRuleIds();
472+
if (!empty($ruleIds)) {
473+
$helper = Mage::helper('nypwidget/rule');
474+
$ruleCollection = Mage::getModel('salesrule/rule')
475+
->getCollection()
476+
->addFieldToFilter('rule_id', array('in' => $ruleIds));
477+
478+
foreach ($ruleCollection as $rule) {
479+
if (!$helper->ruleAppliesToShippingOnly($rule)) {
480+
Mage::getSingleton('core/session')->addNotice(
481+
'Your offer discount could not be applied because of an existing promotion.'
482+
);
483+
return false;
484+
}
485+
}
486+
}
487+
462488
return true;
463489
}
464490

app/code/community/PriceWaiter/NYPWidget/etc/config.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<modules>
55
<PriceWaiter_NYPWidget>
6-
<version>3.0.4</version>
6+
<version>3.0.5</version>
77
</PriceWaiter_NYPWidget>
88
</modules>
99

package.template.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?xml version="1.0"?>
22
<package>
33
<name>nypwidget</name>
4-
<version>3.0.4</version>
4+
<version>3.0.5</version>
55
<stability>stable</stability>
66
<license uri="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License, Version 2.0</license>
77
<channel>community</channel>
88
<extends/>
99
<summary>PriceWaiter lets buyers make offers on your products that you can easily accept, counter offer or reject.</summary>
1010
<description>Sell more, immediately, with PriceWaiter. Convert comparison shoppers you might have lost, increase sales and conversions, and stop "minimum advertised price" from preventing sales before they even start.&#xD;&#xD; PriceWaiter lets customers make offers on products you sell-- offers you can accept, reject or counter. The widget embeds a simple Name Your Price button on any product page or category that you choose. Simply install the extension and you'll have full control over PriceWaiter in your Magento admin control panel.</description>
11-
<notes>Support checkout of deals with free shipping rules.</notes>
11+
<notes>Prevent discount warnings from displaying when no deals are present.</notes>
1212
<authors>
1313
<author>
1414
<name>PriceWaiter</name>

0 commit comments

Comments
 (0)