Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
<?php
namespace SystemCode\BrazilCustomerAttributes\Model\Checkout;

namespace SystemCode\BrazilCustomerAttributes\Plugin\Checkout;

use SystemCode\BrazilCustomerAttributes\Helper\Data as Helper;

/**
*
* Model to add label each address line
*
*
* NOTICE OF LICENSE
*
* @category SystemCode
* @package Systemcode_BrazilCustomerAttributes
* @author Eduardo Diogo Dias <contato@systemcode.com.br>
* @copyright System Code LTDA-ME
* @license http://opensource.org/licenses/osl-3.0.php
* @category SystemCode
* @package Systemcode_BrazilCustomerAttributes
* @author Eduardo Diogo Dias <contato@systemcode.com.br>
* @copyright System Code LTDA-ME
* @license http://opensource.org/licenses/osl-3.0.php
*/
class LayoutProcessorPlugin
class LayoutProcessor
{

/**
* @var Helper
*/
protected $helper;

/**
* @var \SystemCode\BrazilCustomerAttributes\Model\Config\Source\Streetprefix
*/
protected $streetprefix;

/**
* @var Array
*/
protected $streetprefixoptions;

/**
* LayoutProcessorPlugin constructor.
* @param Helper $helper
*
* @param Helper $helper
* @param \SystemCode\BrazilCustomerAttributes\Model\Config\Source\Streetprefix $streetprefix
*/
public function __construct(
Expand All @@ -38,7 +49,7 @@ public function __construct(

/**
* @param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject
* @param array $jsLayout
* @param array $jsLayout
* @return array
*/

Expand All @@ -54,7 +65,8 @@ public function afterProcess(
return $jsLayout;
}

public function setStreetPrefixOptions(){
public function setStreetPrefixOptions()
{
$this->streetprefixoptions = [];

if($this->helper->getConfig("brazilcustomerattributes/general/prefix_enabled")) {
Expand All @@ -67,7 +79,8 @@ public function setStreetPrefixOptions(){
}
}

public function getShippingFormFields($jsLayout, $numStreetLines){
public function getShippingFormFields($jsLayout, $numStreetLines)
{
// Street Label
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children']['street']['label'] = '';
Expand All @@ -82,7 +95,7 @@ public function getShippingFormFields($jsLayout, $numStreetLines){
['shippingAddress']['children']['shipping-address-fieldset']['children']['street']['children'][0]['validation'] = ['required-entry' => true, "min_text_len‌​gth" => 1, "max_text_length" => 255];

// Street Line 1
if($this->helper->getConfig("brazilcustomerattributes/general/line_number") && $numStreetLines >= 2){
if($this->helper->getConfig("brazilcustomerattributes/general/line_number") && $numStreetLines >= 2) {
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children']['street']['children'][1]['label'] = __('Number');
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
Expand Down Expand Up @@ -150,10 +163,10 @@ public function getShippingFormFields($jsLayout, $numStreetLines){
return $jsLayout;
}

public function getBillingFormFields($jsLayout, $numStreetLines){
if(isset($jsLayout['components']['checkout']['children']['steps']['children']
['billing-step']['children']['payment']['children']
['payments-list'])) {
public function getBillingFormFields($jsLayout, $numStreetLines)
{
if(isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list'])
) {

$paymentForms = $jsLayout['components']['checkout']['children']['steps']['children']
['billing-step']['children']['payment']['children']
Expand All @@ -163,8 +176,8 @@ public function getBillingFormFields($jsLayout, $numStreetLines){

$paymentMethodCode = str_replace('-form', '', $paymentMethodForm);

if (!isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list']['children'][$paymentMethodCode . '-form'])) {
if (!isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'][$paymentMethodCode . '-form'])
) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Checkout\Block\Checkout\LayoutProcessor">
<plugin name="rewrite-street" type="SystemCode\BrazilCustomerAttributes\Model\Checkout\LayoutProcessorPlugin" sortOrder="10"/>
<plugin name="rewrite-street" type="SystemCode\BrazilCustomerAttributes\Plugin\Checkout\LayoutProcessor" sortOrder="10"/>
</type>
<type name="Magento\Quote\Model\BillingAddressManagement">
<plugin disabled="false" name="copy-billing" sortOrder="10" type="SystemCode\BrazilCustomerAttributes\Plugin\Quote\BillingAddressManagement"/>
Expand Down