Skip to content

Commit 8ddaad8

Browse files
authored
Merge pull request #142 from breadfinance/shipping-api-fix-accuquilt
PR Shipping api + Targeted financing
2 parents 2b01392 + 43945f3 commit 8ddaad8

File tree

6 files changed

+33
-5
lines changed

6 files changed

+33
-5
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Offers the Bread financing and checkout tools for your Magento store",
44
"license": "MIT",
55
"minimum-stability": "stable",
6-
"version": "1.1.13",
6+
"version": "1.1.15",
77
"require": {
88
"php": "~7.0.13||~7.1.0||~7.1.3||~7.2.0||~7.3.0"
99
},
@@ -19,3 +19,5 @@
1919
}
2020
}
2121
}
22+
23+

view/frontend/requirejs-config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ var config = {
88
map: {
99
'*': {
1010
buttonConfig: 'Bread_BreadCheckout/js/button-config',
11-
bundleHelper: 'Bread_BreadCheckout/js/bundle-helper'
11+
bundleHelper: 'Bread_BreadCheckout/js/bundle-helper',
12+
'Magento_Checkout/js/action/select-shipping-method': 'Bread_BreadCheckout/web/js/shipping-method'
1213
}
1314
}
1415
};

view/frontend/templates/breadcheckout/grouped.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
var cartSizeFinancingId = financingInfo.id;
193193
var cartSizeThreshold = financingInfo.threshold;
194194
var itemsPriceSum = items.reduce(function(sum, item) { return sum + item.price * item.quantity }, 0) / 100;
195-
breadConfig.financingProgramId = (itemsPriceSum >= cartSizeThreshold) ? cartSizeFinancingId : 'null';
195+
breadConfig.financingProgramId = (itemsPriceSum >= cartSizeThreshold) ? cartSizeFinancingId : null;
196196
} else if(financingInfo.enabled && financingInfo.mode.sku){
197197
var productSku = "<?= /* @noEscape */ $block->getProduct()->getSku(); ?>";
198198
if(financingInfo.sku_limit.indexOf(productSku) !== -1){

view/frontend/templates/breadcheckout/list_product.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ $productId = $product->getId();
7979
var cartSizeFinancingId = financingInfo.id;
8080
var cartSizeThreshold = financingInfo.threshold;
8181
var itemsPriceSum = items.reduce(function(sum, item) { return sum + item.price * item.quantity; }, 0) / 100;
82-
breadConfig.financingProgramId = (itemsPriceSum >= cartSizeThreshold) ? cartSizeFinancingId : 'null';
82+
breadConfig.financingProgramId = (itemsPriceSum >= cartSizeThreshold) ? cartSizeFinancingId : null;
8383
} else if (financingInfo.enabled && financingInfo.mode.sku){
8484
var productSku = "<?= /* @noEscape */ $block->getProduct()->getSku(); ?>";
8585
if(financingInfo.sku_limit.indexOf(productSku) !== -1){

view/frontend/templates/breadcheckout/view.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
var cartSizeFinancingId = financingInfo.id;
200200
var cartSizeThreshold = financingInfo.threshold;
201201
var itemsPriceSum = items.reduce(function(sum, item) { return sum + item.price * item.quantity; }, 0) / 100;
202-
breadConfig.financingProgramId = (itemsPriceSum >= cartSizeThreshold) ? cartSizeFinancingId : 'null';
202+
breadConfig.financingProgramId = (itemsPriceSum >= cartSizeThreshold) ? cartSizeFinancingId : null;
203203
} else if (financingInfo.enabled && financingInfo.mode.sku){
204204
var productSku = "<?= /* @noEscape */ $block->getProduct()->getSku(); ?>";
205205
if(financingInfo.sku_limit.indexOf(productSku) !== -1){
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
define([
2+
'jquery',
3+
'Magento_Checkout/js/model/quote',
4+
'Magento_Checkout/js/action/set-shipping-information'
5+
], function (
6+
$,
7+
quote,
8+
setShippingInformationAction
9+
) {
10+
'use strict';
11+
12+
return function (shippingMethod) {
13+
//Re-evaluate selected shippingMethod
14+
quote.shippingMethod(shippingMethod);
15+
if (shippingMethod != null) {
16+
//Invalidate existing transactionId if customer had already filled payment form
17+
//and steps back
18+
if (window.checkoutConfig.payment.breadcheckout.transactionId !== null) {
19+
window.checkoutConfig.payment.breadcheckout.transactionId = null;
20+
}
21+
//Set back payment method(Pay Later Bread) to ensure it checked when customer selects next
22+
quote.paymentMethod(null);
23+
}
24+
};
25+
});

0 commit comments

Comments
 (0)