0

app/code/Vendor/Module/Model/CustomConfigProvider.php (data provider)

<?php

namespace Vendor\Module\Model;

use Magento\Checkout\Model\ConfigProviderInterface;

class CustomConfigProvider implements ConfigProviderInterface
{

    public function getConfig()
    {        
        $storepick_config = array();    
        $storepick_config[] = ['value' => 1, 'label' => 'label1'];
        $storepick_config[] = ['value' => 2, 'label' => 'label2'];
        $storepick_config[] = ['value' => 3, 'label' => 'label3'];
        $storepick_config[] = ['value' => 4, 'label' => 'label4'];


        $config = [
            'storepick_config' => $storepick_config,
            'storepick_config_encode' => json_encode($storepick_config),
        ];
        return $config;
    }


}
?>

app/code/Vendor/Module/view/frontend/web/js/view/checkout/shipping/storepickup.js

define([
    'jquery',
    'ko',
    'uiComponent',
    'Magento_Checkout/js/model/quote'
], function ($, ko, Component, quote) {
    'use strict';   

    console.log(window.checkoutConfig.storepick_config);
    console.log(window.checkoutConfig.storepick_config_encode);

    return Component.extend({
        defaults: {
            template: 'Vendor_Module/checkout/shipping/storepickup',
            storepickConfig: window.checkoutConfig.storepick_config,
            storepick_config_encode:window.checkoutConfig.storepick_config_encode,

        },      

    });
});

app/code/Vendor/Module/view/frontend/web/template/checkout/shipping/storepickup.html

<select data-bind="options:storepickConfig"></select>

now i want require drop down in checkout page but drop down not display proper way

i want to display store list in drop down Please help if any one know

0

You are missing the di.xml file.

/vendor/vendorName/module-myModule/etc/frontend/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">
    <type name="Magento\Checkout\Model\CompositeConfigProvider">
        <arguments>
            <argument name="configProviders" xsi:type="array">
                <item name="my_custom_config_provider" xsi:type="object">Vendor\ModuleName\Model\MyCustomConfigProvider</item>
            </argument>
        </arguments>
    </type>
</config>

After this, clear all caches and check.

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.