Skip to content

Commit

Permalink
Merge pull request #85 from Paazl/release/1.10.0
Browse files Browse the repository at this point in the history
Release/1.10.0
  • Loading branch information
Marvin-Magmodules authored Jan 19, 2022
2 parents 41b6288 + 7c9aa9a commit bbe79ca
Show file tree
Hide file tree
Showing 22 changed files with 26,874 additions and 21 deletions.
32 changes: 32 additions & 0 deletions Block/Checkout/Address.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Copyright © 2019 Paazl. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Paazl\CheckoutWidget\Plugin\Multishipping\Block\Checkout;

use Magento\Multishipping\Block\Checkout\Shipping as Subject;
use Paazl\CheckoutWidget\Model\Carrier\Paazlshipping;

/**
* Class Address
*/
class Address
{
/**
* @param Subject $subject
* @param $groups
*
* @return mixed
*/
public function afterGetShippingRates(Subject $subject, $groups)
{
foreach ($groups as $code => $rates) {
if ($code == Paazlshipping::CODE) {
unset($groups[$code]);
}
}
return $groups;
}
}
1 change: 1 addition & 0 deletions Model/Checkout/PaazlConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function getConfig()
$config['widgetConfig'] = $this->widgetConfigProvider->getConfig();
$config['mode'] = $this->config->isProductionApiMode() ? 'live' : 'test';
$config['showOnFirstLoad'] = $this->config->showWidgetOnFirstLoad();
$config['useLocalCopyOfWidgetJs'] = $this->config->isUseLocalCopyOfWidgetJs();

if (empty($config['widgetConfig']['token'])) {
// We were unable to obtain a token - enabling other methods if they're available
Expand Down
12 changes: 7 additions & 5 deletions Model/Checkout/WidgetConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function getConfig()
foreach ($this->getQuote()->getAllItems() as $item) {
if ($item->getProductType() == 'simple') {
$goodsItem = [
"quantity" => (int)$item->getQty(),
"quantity" => $item->getParentItem() ? (int)($item->getParentItem()->getQty()) : (int)$item->getQty(),
"weight" => doubleval($item->getWeight()),
"price" => $this->itemHandler->getPriceValue($item)
];
Expand Down Expand Up @@ -193,7 +193,7 @@ public function getConfig()
"sortOrder" => "ASC"
],
"shipmentParameters" => [
"totalWeight" => (float)$this->getTotalWeight(),
"totalWeight" => (float)$this->getTotalWeight($goods),
"totalPrice" => (float)$this->getQuote()->getSubtotalWithDiscount(),
"numberOfGoods" => (int)$this->getProductsCount(),
"goods" => $goods
Expand Down Expand Up @@ -335,12 +335,14 @@ public function getNominatedDateEnabled()
/**
* @return float
*/
public function getTotalWeight()
public function getTotalWeight($goods)
{
$weight = 0;
$quote = $this->getQuote();
foreach ($quote->getAllVisibleItems() as $_item) {
$weight += $_item->getWeight();
foreach ($goods as $good) {
if (isset($good['weight']) && isset($good['quantity'])) {
$weight += ($good['weight'] * $good['quantity']);
}
}
return $weight;
}
Expand Down
10 changes: 10 additions & 0 deletions Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,16 @@ public function saveShippingInformationInstantly($store = null)
return !!$this->getValue(self::API_CONFIG_PATH . '/onestep_checkout_used', $store);
}

/**
* @param null|Store|int|string $store
*
* @return bool
*/
public function isUseLocalCopyOfWidgetJs($store = null)
{
return !!$this->getValue(self::API_CONFIG_PATH . '/use_local_js_for_widget', $store);
}

/**
* @param null|Store|int|string $store
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* Class Resource
*/
class Resource extends Address
class ResourceModel extends Address
{
/**
* @param int $quoteId
Expand Down
2 changes: 1 addition & 1 deletion Plugin/Tax/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Paazl\CheckoutWidget\Helper\Order as OrderHelper;
use Paazl\CheckoutWidget\Model\Config as PaazlConfig;
use Magento\Checkout\Model\Session;
use Paazl\CheckoutWidget\Model\ResourceModel\QuoteAddress\Resource as QuoteAddressResource;
use Paazl\CheckoutWidget\Model\ResourceModel\QuoteAddress\ResourceModel as QuoteAddressResource;

/**
* Tax Config Plugin
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "paazl/magento2-checkout-widget",
"description": "Paazl checkoutWidget for Magento 2",
"type": "magento2-module",
"version": "1.9.3",
"version": "1.10.0",
"keywords": [
"Paazl",
"Magento 2",
Expand Down
5 changes: 5 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>OneStepCheckout, Custom Checkout etc.</comment>
</field>
<field id="use_local_js_for_widget" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
<label>Use local JS file for widget initialization?</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>Local copy will be used instead of external JS (from *.paazl.com).</comment>
</field>
</group>
</section>
</system>
Expand Down
3 changes: 2 additions & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<default>
<carriers>
<paazlshipping>
<version>v1.9.3</version>
<version>v1.10.0</version>
<active>0</active>
<sallowspecific>0</sallowspecific>
<price>0</price>
Expand All @@ -34,6 +34,7 @@
<insurance_value>0</insurance_value>
<housenumber_default_value>1</housenumber_default_value>
<total_price>subtotal_incl_discount</total_price>
<use_local_js_for_widget>0</use_local_js_for_widget>
</paazlshipping>
</carriers>
</default>
Expand Down
4 changes: 4 additions & 0 deletions etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<type name="Magento\Quote\Model\Quote\Address\RateCollectorInterface">
<plugin name="paazl_checkoutwidget" type="\Paazl\CheckoutWidget\Plugin\Shipping\RateCollectorPlugin"/>
</type>
<type name="Magento\Multishipping\Block\Checkout\Shipping">
<plugin name="paazl_disable_multishipping"
type="Paazl\CheckoutWidget\Plugin\Multishipping\Block\Checkout\Address"/>
</type>

<type name="Magento\Checkout\Model\CompositeConfigProvider">
<arguments>
Expand Down
Binary file modified view/adminhtml/web/images/paazl_brand.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified view/adminhtml/web/images/paazl_icon.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified view/adminhtml/web/images/paazl_logo.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 11 additions & 3 deletions view/base/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ var config = {
widgetConfig: 'Paazl_CheckoutWidget/js/checkout/view/widget-config',
paazlShippingModal: 'Paazl_CheckoutWidget/js/admin/order/create/paazl-shipping/modal',
customJs: 'Paazl_CheckoutWidget/js/custom',
checkoutjs_test: "https://widget-acc.paazl.com/v1/checkout.js",
checkoutjs_live: "https://widget.paazl.com/v1/checkout.js"
checkoutjs_local_test: "Paazl_CheckoutWidget/js/checkout/lib/checkout_local_test",
checkoutjs_local_live: "Paazl_CheckoutWidget/js/checkout/lib/checkout_local_live"
}
},
paths: {
paazlCheckout: 'Paazl_CheckoutWidget/js/checkout'
paazlCheckout: 'Paazl_CheckoutWidget/js/checkout',
checkoutjs_test: [
"https://widget-acc.paazl.com/v1/checkout",
"Paazl_CheckoutWidget/js/checkout/lib/checkout_local_test"
],
checkoutjs_live: [
"https://widget.paazl.com/v1/checkout",
"Paazl_CheckoutWidget/js/checkout/lib/checkout_local_live"
],
},
shim: {
'Paazl_CheckoutWidget/js/checkout': {
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/layout/checkout_index_index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column"
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
Expand Down
3 changes: 3 additions & 0 deletions view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ var config = {
'Magento_Checkout/js/action/set-shipping-information': {
'Paazl_CheckoutWidget/js/checkout/action/set-shipping-information-mixin': true
},
'Magento_Checkout/js/view/billing-address': {
'Paazl_CheckoutWidget/js/checkout/view/billing-address-mixin': true
},
'Magento_Checkout/js/model/checkout-data-resolver': {
'Paazl_CheckoutWidget/js/checkout/model/checkout-data-resolver-mixin': true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,40 @@ define(
[
'underscore',
'Magento_Checkout/js/model/quote',
'widgetConfig'
'widgetConfig',
'mage/utils/wrapper',
'Paazl_CheckoutWidget/js/checkout/model/shipping-locations'
],
function (
_,
quote,
widgetConfig
widgetConfig,
wrapper,
shippingLocations
) {
return function (target) {
return function () {
return target().done(function (res) {
return wrapper.wrap(target, function (originalAction) {
var shippingMethod = quote.shippingMethod();
if (shippingLocations.selectedLocationCode()
&& shippingLocations.locationsList().length
&& shippingMethod
&& widgetConfig.prototype.getCarrierCode() === shippingMethod.carrier_code
&& widgetConfig.prototype.getMethodCode() === shippingMethod.method_code) {
var collectionPointInfo =_.findWhere(shippingLocations.locationsList(), {code: shippingLocations.selectedLocationCode()}),
shippingAddress = quote.shippingAddress();
if (collectionPointInfo && collectionPointInfo.address) {
shippingAddress.countryId = collectionPointInfo.address.country;
shippingAddress.city = collectionPointInfo.address.city;
shippingAddress.postcode = collectionPointInfo.address.postalCode;
shippingAddress.street = [
collectionPointInfo.address.street,
collectionPointInfo.address.streetNumber
];
quote.shippingAddress(shippingAddress);
}
}

return originalAction().done(function (res) {
var shippingMethod = quote.shippingMethod();
if (widgetConfig.prototype.getCarrierCode() !== shippingMethod.carrier_code
|| widgetConfig.prototype.getMethodCode() !== shippingMethod.method_code) {
Expand All @@ -41,7 +65,7 @@ define(

found && quote.shippingMethod(found);
})
}
});
}
}
);
1 change: 1 addition & 0 deletions view/frontend/web/js/checkout/lib/checkout_local_live.js

Large diffs are not rendered by default.

Loading

0 comments on commit bbe79ca

Please sign in to comment.