Skip to content

Commit

Permalink
Merge pull request #126 from breadfinance/develop
Browse files Browse the repository at this point in the history
Release version 1.1.11
  • Loading branch information
aleksa-andersinnovation authored Oct 30, 2019
2 parents c3fd7ae + b432d20 commit f6aee86
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 56 deletions.
9 changes: 8 additions & 1 deletion Controller/Adminhtml/Bread/GenerateCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,20 @@ public function execute()
$arr['options']['shippingContact'] = $this->helper->getShippingAddressData();
$arr['options']['billingContact'] = $this->helper->getBillingAddressData();

if (!$this->helper->isHealthcare()) {
if (!$this->helper->isHealthcare() && !$quote->getUseRewardPoints()) {
$arr['options']['items'] = $this->helper->getQuoteItemsData();
} else {
$arr['options']['customTotal'] = round($quote->getGrandTotal() * 100);
}

$arr['options']['discounts'] = $this->helper->getDiscountData() ? $this->helper->getDiscountData() : [];
if($quote->getUseRewardPoints()){
array_push($arr['options']['discounts'],
array(
'amount' => round($quote->getRewardCurrencyAmount() * 100),
'description' => __('Reward Points')
));
}

$arr['options']['tax'] = $this->helper->getTaxValue();

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Offers the Bread financing and checkout tools for your Magento store",
"license": "MIT",
"minimum-stability": "stable",
"version": "1.1.10",
"version": "1.1.11",
"require": {
"php": "~7.0.13||~7.1.0||~7.1.3||~7.2.0||~7.3.0"
},
Expand Down
11 changes: 4 additions & 7 deletions view/frontend/templates/breadcheckout/cartview.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>

<script type="text/javascript">
require(['jquery', 'jquery/validate', 'mage/validation'], function($, quote) {
require(['jquery', 'jquery/validate', 'mage/validation', '!domReady'], function($) {

var validateProductTypes = Boolean(<?= /* @noEscape */ $block->validateAllowedProductTypes() ?>);
if (validateProductTypes === false) {
Expand Down Expand Up @@ -214,11 +214,8 @@
return parseInt(Math.round(value * 100));
};

$(document).ready(function() {
document.defaultItems = <?= /* @noEscape */ $block->getProductDataJson(); ?>;
document.previousPrice = document.defaultItems[0]["price"];
document.previousSku = document.defaultItems[0]["sku"];
document.configureButton(document.defaultItems);
});
document.defaultItems = <?= /* @noEscape */ $block->getProductDataJson(); ?>;
document.configureButton(document.defaultItems);

});
</script>
2 changes: 1 addition & 1 deletion view/frontend/templates/breadcheckout/configurable.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
attributes: this.attributes,
selected_options: selectedOptions
};
document.logBreadIssue('info', logInfo, 'Using old version of getIdOfSelectedProduct');

$.each(this.attributes, function(attrId, attrVal) {
var optionId = selectedOptions[attrId];
Expand All @@ -102,6 +101,7 @@
});

if (this.productIds.length === 1) {
document.logBreadIssue('info', logInfo, 'Old version of getIdOfSelectedProduct found item');
return this.productIds[0];
} else {
return null;
Expand Down
94 changes: 48 additions & 46 deletions view/frontend/web/js/button-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,55 +91,55 @@ define(
* @private
*/
_init: function () {

var self = this;

if (window.checkoutConfig.payment.breadcheckout.transactionId === null) {

if(typeof this.breadConfig.shippingOptions !== "undefined" && this.breadConfig.shippingOptions[0] !== false) {

this.checkShippingOptions(function () {
if (typeof bread !== 'undefined') {
bread.showCheckout(this.breadConfig);
bread.showCheckout(self.breadConfig);
fullScreenLoader.stopLoader();
}
});
}
},

} else if(typeof this.breadConfig.shippingOptions === "undefined" && quote.isVirtual()) {
/**
* Makes sure shipping options are up to date
*/
checkShippingOptions: function (cb) {
var self = this;

this.breadConfig.customTotal = this.round(quote.getTotals()._latestValue.base_grand_total);
if (typeof bread !== 'undefined') {
bread.showCheckout(this.breadConfig);
if(typeof this.breadConfig.shippingOptions !== "undefined" && this.breadConfig.shippingOptions[0] !== false) {
cb();
} else if(typeof this.breadConfig.shippingOptions === "undefined" && quote.isVirtual()) {
this.breadConfig.customTotal = this.round(quote.getTotals()._latestValue.base_grand_total);
cb();
} else {
/* ocs save selected shipping method */
var shippingOptionUrl = window.checkoutConfig.payment.breadcheckout.shippingOptionUrl;
$.ajax(
{
url: shippingOptionUrl,
type: 'post',
context: this
}
} else {
/* ocs save selected shipping method */
var shippingOptionUrl = window.checkoutConfig.payment.breadcheckout.shippingOptionUrl;
$.ajax(
{
url: shippingOptionUrl,
type: 'post',
context: this
}
).done(
function (data) {
self.breadConfig.shippingOptions = [data];
self.breadConfig.customTotal = this.round(quote.getTotals()._latestValue.base_grand_total);
if (typeof bread !== 'undefined') {
bread.showCheckout(self.breadConfig);
}
}
).fail(
function (error) {
var errorInfo = {
bread_config: self.breadConfig
};
document.logBreadIssue(
'error', errorInfo,
'Error code returned when calling ' + shippingOptionUrl + ', with status: ' + error.statusText
);
}
);
}

).done(
function (data) {
self.breadConfig.shippingOptions = [data];
self.breadConfig.customTotal = self.round(quote.getTotals()._latestValue.base_grand_total);
cb();
}
).fail(
function (error) {
var errorInfo = {
bread_config: self.breadConfig
};
document.logBreadIssue(
'error', errorInfo,
'Error code returned when calling ' + shippingOptionUrl + ', with status: ' + error.statusText
);
}
);
}

},

/**
Expand All @@ -156,10 +156,14 @@ define(
* @private
*/
_initEmbedded: function () {
var self = this;
if (window.checkoutConfig.payment.breadcheckout.transactionId === null) {
if (typeof bread !== 'undefined') {
bread.checkout(this.breadConfig);
}
this.checkShippingOptions(function () {
if (typeof bread !== 'undefined') {
bread.checkout(self.breadConfig);
fullScreenLoader.stopLoader();
}
});
}
},

Expand Down Expand Up @@ -194,8 +198,6 @@ define(
this.breadConfig.shippingContact = data.billingContact;
}

fullScreenLoader.stopLoader();

if(isEmbedded === false) {
this._init();
} else {
Expand Down

0 comments on commit f6aee86

Please sign in to comment.