Skip to content
Snippets Groups Projects
Commit 0140606e authored by Gundo Sifhufhi's avatar Gundo Sifhufhi
Browse files

Add Shipping Address `Suburb` Information.

Added KnockoutJs mixins.
Updated LayoutProcessor.
parent 1b1ba7a4
Branches
Tags
No related merge requests found
......@@ -14,6 +14,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\DataObject;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\HTTP\Client\CurlFactory;
use Magento\Framework\Module\Dir\Reader;
use Magento\Framework\Xml\Security;
......@@ -235,7 +236,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\
$destCity = $request->getDestCity();
$destStreet = $request->getDestStreet();
list($destStreet1, $destStreet2) = $this->destStreet($destStreet);
list($destStreet1, $destStreet2, $destStreet3) = $this->destStreet($destStreet);
/** Collection Origin Information */
list($originStreet, $originRegion, $originCountry, $originCity, $originStreet1, $originStreet2, $storeName, $baseIdentifier, $originSuburb) = $this->storeInformation();
......@@ -271,7 +272,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\
'company' => $destComp,
'address1' => $destStreet1,
'address2' => $destStreet2,
'suburb' => '',
'suburb' => $destStreet3,
'city' => $destCity,
'province' => $destRegion,
'country_code' => $destCountry,
......@@ -872,10 +873,12 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\
$destStreet = explode("\n", $destStreet);
$destStreet1 = $destStreet[0];
$destStreet2 = $destStreet[1];
$destStreet3 = $destStreet[2] ?? '';
} else {
$destStreet1 = $destStreet;
$destStreet2 = '';
$destStreet3 = '';
}
return array($destStreet1, $destStreet2);
return array($destStreet1, $destStreet2, $destStreet3);
}
}
<?php
namespace uafrica\Customshipping\Model\Carrier;
use Magento\Checkout\Api\Data\ShippingInformationInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Quote\Api\CartRepositoryInterface;
class uSub {
/**
* @throws NoSuchEntityException
*/
public function getDestSuburb()
{
$objectManager = ObjectManager::getInstance();
$quote = $objectManager->get('Magento\Checkout\Model\ShippingInformation')->getExtensionAttributes();
return $quote->getSuburb();
}
}
......@@ -35,11 +35,11 @@ class LayoutProcessorPlugin
'id' => 'suburb'
],
'dataScope' => 'shippingAddress.extension_attributes.suburb',
'label' => 'Suburb',
'label' => 'Suburb(BobGo Required)',
'provider' => 'checkoutProvider',
'visible' => true,
'visible' => false,
'validation' => [
'required-entry' => true
'required-entry' => false
],
'sortOrder' => 110,
/*'customEntry' => null,*/
......
var config = {
config: {
mixins: {
'Magento_Checkout/js/action/set-shipping-information': {
'uafrica_Customshipping/js/action/set-shipping-information-mixin': true
}
}
}
};
/*jshint browser:true jquery:true*/
/*global alert*/
define([
'jquery',
'mage/utils/wrapper',
'Magento_Checkout/js/model/quote'
], function ($, wrapper, quote) {
'use strict';
return function (setShippingInformationAction) {
return wrapper.wrap(setShippingInformationAction, function (originalAction) {
var shippingAddress = quote.shippingAddress();
if (shippingAddress['extension_attributes'] === undefined) {
shippingAddress['extension_attributes'] = {};
}
// var attribute = shippingAddress.customAttributes.find(
// function (element) {
// return element.attribute_code === 'suburb';
// }
// );
//
// shippingAddress['extension_attributes']['suburb'] = attribute.value;
// shippingAddress['extension_attributes']['suburb'] = shippingAddress.value;
// pass execution to original action ('Magento_Checkout/js/action/set-shipping-information')
return originalAction();
});
};
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment