1

i need to delete "zip code" text field from cehckout page in magento 2. For that i following this answers: ANSWER but i don't know how to add my class which will set default value '00000' for "zip code" text field and don't know how to override code xml in own plugin. I created own plugin, please tell me what i doing wrong in building own plugin.

Folders tree:

  --/app/code/Rockforweb/CheckoutZipcode
  --Data/
    --Address.php
  --etc/
    --di.xml
    --module.xml
  --view/
    --frontend/
      --page_layout/
        --checkout_index_index.xml
  --composer.json
  --registration.php

FILES CONTENT:

registration.php:

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Rockforweb_CheckoutZipcode',
    __DIR__
);

composer.json:

{
    "name": "Rockforweb\/CheckoutZipcode",
    "description": "",
    "require": {
        "php": "~5.5.0|~5.6.0|~7.0.0"
    },
    "type": "magento2-module",
    "version": "2.1.2",
    "license": [
        "Proprietary"
    ],
    "autoload": {
        "files": [
            "registration.php"
        ],
        "psr-4": {
            "Rockforweb\\CheckoutZipcode\\": ""
        }
    },
    "extra": {
        "map": [
            [
                "*",
                "Rockforweb\/CheckoutZipcode"
            ]
        ]
    }
}

checkout_index_index.xml:

checkout_index_index.xml

di.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
     <preference for="Magento\Quote\Model\Quote\Address"
                 type="Rockforweb\CheckoutZipcode\Data\Address" />
</config>

module.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Rockforweb_CheckoutZipcode" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Quote" />
        </sequence>
    </module>
</config>

Address.php:

<?php
namespace Rockforweb\CheckoutZipcode\Data;

class CheckoutZipcode extends Magento\Quote\Model\Quote\Address
{
    public function afterGetPostcode()
    {
        return '00000';
    }
}
  • are you fixed this issue? – Rajkumar .E Aug 29 '17 at 2:17
1

Change Page layout to Layout

--view/
 --frontend/
  --layout/
    --checkout_index_index.xml

And Change Address.php class name to Address

class Address extends Magento\Quote\Model\Quote\Address
{
    public function afterGetPostcode()
    {
        return '00000';
    }
}

Then, Clear cache and check it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.