Skip to content

Commit baaa945

Browse files
author
Roman Lytvynenko
committed
Merge branches 'MC-17459' and 'MC-17551' of https://github.com/magento-mpi/magento2ce into PR-M22-06-27-19
3 parents 18501ec + 53c472a + 4ae7c0c commit baaa945

File tree

11 files changed

+88
-93
lines changed

11 files changed

+88
-93
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/multishipping/cc-form.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ define([
1212
'Magento_Ui/js/model/messageList',
1313
'mage/translate',
1414
'Magento_Checkout/js/model/full-screen-loader',
15-
'Magento_Checkout/js/action/set-payment-information',
15+
'Magento_Checkout/js/action/set-payment-information-extended',
1616
'Magento_Checkout/js/model/payment/additional-validators',
1717
'Magento_Braintree/js/view/payment/validator-handler'
1818
], function (
@@ -22,7 +22,7 @@ define([
2222
messageList,
2323
$t,
2424
fullScreenLoader,
25-
setPaymentInformationAction,
25+
setPaymentInformationExtended,
2626
additionalValidators,
2727
validatorManager
2828
) {
@@ -51,9 +51,10 @@ define([
5151
if (additionalValidators.validate()) {
5252
fullScreenLoader.startLoader();
5353
$.when(
54-
setPaymentInformationAction(
54+
setPaymentInformationExtended(
5555
this.messageContainer,
56-
this.getData()
56+
this.getData(),
57+
true
5758
)
5859
).done(this.done.bind(this))
5960
.fail(this.fail.bind(this));

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/multishipping/paypal.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ define([
88
'jquery',
99
'underscore',
1010
'Magento_Braintree/js/view/payment/method-renderer/paypal',
11-
'Magento_Checkout/js/action/set-payment-information',
11+
'Magento_Checkout/js/action/set-payment-information-extended',
1212
'Magento_Checkout/js/model/payment/additional-validators',
1313
'Magento_Checkout/js/model/full-screen-loader'
1414
], function (
1515
$,
1616
_,
1717
Component,
18-
setPaymentInformationAction,
18+
setPaymentInformationExtended,
1919
additionalValidators,
2020
fullScreenLoader
2121
) {
@@ -131,9 +131,10 @@ define([
131131
placeOrder: function () {
132132
fullScreenLoader.startLoader();
133133
$.when(
134-
setPaymentInformationAction(
134+
setPaymentInformationExtended(
135135
this.messageContainer,
136-
this.getData()
136+
this.getData(),
137+
true
137138
)
138139
).done(this.done.bind(this))
139140
.fail(this.fail.bind(this));
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/**
7+
* @api
8+
*/
9+
define([
10+
'Magento_Checkout/js/model/quote',
11+
'Magento_Checkout/js/model/url-builder',
12+
'mage/storage',
13+
'Magento_Checkout/js/model/error-processor',
14+
'Magento_Customer/js/model/customer',
15+
'Magento_Checkout/js/action/get-totals',
16+
'Magento_Checkout/js/model/full-screen-loader'
17+
], function (quote, urlBuilder, storage, errorProcessor, customer, getTotalsAction, fullScreenLoader) {
18+
'use strict';
19+
20+
return function (messageContainer, paymentData, skipBilling) {
21+
var serviceUrl,
22+
payload;
23+
24+
skipBilling = skipBilling || false;
25+
payload = {
26+
cartId: quote.getQuoteId(),
27+
paymentMethod: paymentData
28+
};
29+
30+
/**
31+
* Checkout for guest and registered customer.
32+
*/
33+
if (!customer.isLoggedIn()) {
34+
serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/set-payment-information', {
35+
cartId: quote.getQuoteId()
36+
});
37+
payload.email = quote.guestEmail;
38+
} else {
39+
serviceUrl = urlBuilder.createUrl('/carts/mine/set-payment-information', {});
40+
}
41+
42+
if (skipBilling === false) {
43+
payload.billingAddress = quote.billingAddress();
44+
}
45+
46+
fullScreenLoader.startLoader();
47+
48+
return storage.post(
49+
serviceUrl, JSON.stringify(payload)
50+
).fail(
51+
function (response) {
52+
errorProcessor.process(response, messageContainer);
53+
}
54+
).always(
55+
function () {
56+
fullScreenLoader.stopLoader();
57+
}
58+
);
59+
};
60+
});

app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information.js

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,13 @@
77
* @api
88
*/
99
define([
10-
'Magento_Checkout/js/model/quote',
11-
'Magento_Checkout/js/model/url-builder',
12-
'mage/storage',
13-
'Magento_Checkout/js/model/error-processor',
14-
'Magento_Customer/js/model/customer',
15-
'Magento_Checkout/js/action/get-totals',
16-
'Magento_Checkout/js/model/full-screen-loader'
17-
], function (quote, urlBuilder, storage, errorProcessor, customer, getTotalsAction, fullScreenLoader) {
10+
'Magento_Checkout/js/action/set-payment-information-extended'
11+
12+
], function (setPaymentInformationExtended) {
1813
'use strict';
1914

2015
return function (messageContainer, paymentData) {
21-
var serviceUrl,
22-
payload;
23-
24-
/**
25-
* Checkout for guest and registered customer.
26-
*/
27-
if (!customer.isLoggedIn()) {
28-
serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/set-payment-information', {
29-
cartId: quote.getQuoteId()
30-
});
31-
payload = {
32-
cartId: quote.getQuoteId(),
33-
email: quote.guestEmail,
34-
paymentMethod: paymentData,
35-
billingAddress: quote.billingAddress()
36-
};
37-
} else {
38-
serviceUrl = urlBuilder.createUrl('/carts/mine/set-payment-information', {});
39-
payload = {
40-
cartId: quote.getQuoteId(),
41-
paymentMethod: paymentData,
42-
billingAddress: quote.billingAddress()
43-
};
44-
}
45-
46-
fullScreenLoader.startLoader();
4716

48-
return storage.post(
49-
serviceUrl, JSON.stringify(payload)
50-
).fail(
51-
function (response) {
52-
errorProcessor.process(response, messageContainer);
53-
}
54-
).always(
55-
function () {
56-
fullScreenLoader.stopLoader();
57-
}
58-
);
17+
return setPaymentInformationExtended(messageContainer, paymentData, false);
5918
};
6019
});

app/code/Magento/Payment/view/frontend/web/js/view/payment/iframe.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,7 @@ define([
125125
this.isPlaceOrderActionAllowed(false);
126126

127127
$.when(
128-
setPaymentInformationAction(
129-
this.messageContainer,
130-
{
131-
method: this.getCode()
132-
}
133-
)
128+
this.setPaymentInformation()
134129
).done(
135130
this.done.bind(this)
136131
).fail(
@@ -145,6 +140,18 @@ define([
145140
}
146141
},
147142

143+
/**
144+
* {Function}
145+
*/
146+
setPaymentInformation: function () {
147+
setPaymentInformationAction(
148+
this.messageContainer,
149+
{
150+
method: this.getCode()
151+
}
152+
);
153+
},
154+
148155
/**
149156
* {Function}
150157
*/

app/code/Magento/SalesRule/Model/Coupon/Massgenerator.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,10 @@ public function generatePool()
168168
++$attempt;
169169
} while ($this->getResource()->exists($code));
170170

171-
$expirationDate = $this->getToDate();
172-
if ($expirationDate instanceof \DateTimeInterface) {
173-
$expirationDate = $expirationDate->format('Y-m-d H:i:s');
174-
}
175-
176171
$coupon->setId(null)
177172
->setRuleId($this->getRuleId())
178173
->setUsageLimit($this->getUsesPerCoupon())
179174
->setUsagePerCustomer($this->getUsagePerCustomer())
180-
->setExpirationDate($expirationDate)
181175
->setCreatedAt($nowTimestamp)
182176
->setType(\Magento\SalesRule\Helper\Coupon::COUPON_TYPE_SPECIFIC_AUTOGENERATED)
183177
->setCode($code)

app/code/Magento/SalesRule/Model/CouponRepository.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ public function save(\Magento\SalesRule\Api\Data\CouponInterface $coupon)
119119
__('Specified rule does not allow auto generated coupons')
120120
);
121121
}
122-
$coupon->setExpirationDate($rule->getToDate());
123122
$coupon->setUsageLimit($rule->getUsesPerCoupon());
124123
$coupon->setUsagePerCustomer($rule->getUsesPerCustomer());
125124
} catch (\Exception $e) {

app/code/Magento/SalesRule/Model/ResourceModel/Coupon.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ protected function _construct()
3434
*/
3535
public function _beforeSave(AbstractModel $object)
3636
{
37-
if (!$object->getExpirationDate()) {
38-
$object->setExpirationDate(null);
39-
} elseif ($object->getExpirationDate() instanceof \DateTimeInterface) {
40-
$object->setExpirationDate(
41-
$object->getExpirationDate()->format('Y-m-d H:i:s')
42-
);
43-
}
44-
4537
// maintain single primary coupon per rule
4638
$object->setIsPrimary($object->getIsPrimary() ? 1 : null);
4739

@@ -126,13 +118,6 @@ public function updateSpecificCoupons(\Magento\SalesRule\Model\Rule $rule)
126118
$updateArray['usage_per_customer'] = $rule->getUsesPerCustomer();
127119
}
128120

129-
$ruleNewDate = new \DateTime($rule->getToDate());
130-
$ruleOldDate = new \DateTime($rule->getOrigData('to_date'));
131-
132-
if ($ruleNewDate != $ruleOldDate) {
133-
$updateArray['expiration_date'] = $rule->getToDate();
134-
}
135-
136121
if (!empty($updateArray)) {
137122
$this->getConnection()->update(
138123
$this->getTable('salesrule_coupon'),

app/code/Magento/SalesRule/Model/ResourceModel/Rule/Collection.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,6 @@ private function getCouponCodeSelect($couponCode)
231231

232232
$this->joinCouponTable($couponCode, $couponSelect);
233233

234-
$notExpired = $this->getConnection()->quoteInto(
235-
'(rule_coupons.expiration_date IS NULL OR rule_coupons.expiration_date >= ?)',
236-
$this->_date->date()->format('Y-m-d')
237-
);
238-
239234
$isAutogenerated =
240235
$this->getConnection()->quoteInto('main_table.coupon_type = ?', Rule::COUPON_TYPE_AUTO)
241236
. ' AND ' .
@@ -250,7 +245,7 @@ private function getCouponCodeSelect($couponCode)
250245
. ')';
251246

252247
$couponSelect->where(
253-
"$notExpired AND ($isAutogenerated OR $isValidSpecific)",
248+
"$isAutogenerated OR $isValidSpecific",
254249
null,
255250
Select::TYPE_CONDITION
256251
);

app/code/Magento/SalesRule/Model/Rule.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,6 @@ public function afterSave()
296296
$this->getUsesPerCoupon() ? $this->getUsesPerCoupon() : null
297297
)->setUsagePerCustomer(
298298
$this->getUsesPerCustomer() ? $this->getUsesPerCustomer() : null
299-
)->setExpirationDate(
300-
$this->getToDate()
301299
)->save();
302300
} else {
303301
$this->getPrimaryCoupon()->delete();
@@ -499,8 +497,6 @@ public function acquireCoupon($saveNewlyCreated = true, $saveAttemptCount = 10)
499497
$this->getUsesPerCoupon() ? $this->getUsesPerCoupon() : null
500498
)->setUsagePerCustomer(
501499
$this->getUsesPerCustomer() ? $this->getUsesPerCustomer() : null
502-
)->setExpirationDate(
503-
$this->getToDate()
504500
)->setType(
505501
\Magento\SalesRule\Api\Data\CouponInterface::TYPE_GENERATED
506502
);

0 commit comments

Comments
 (0)