0

I am getting an issue on a single page (caught ReferenceError: require is not defined) on the below code. Please help me to resolve this issue. I am not sure where I am getting this issue I inspected some code then I found this one. due to this CSS not loading but it doesn't shown me any css issue. Can anyone help me out on this.

    <?php
    $helper = $this->helper('Webkul\B2BMarketplace\Helper\Data');
    $helper->getCompanyName();
    $baseUrl = $helper->getBaseUrl()."pub/media/b2b/";
    $regions = $helper->getAllRegions();

    $corporateAddress = $helper->getCorporateAddress();
    $operatioanlAddress = $helper->getOperatioanlAddress();
    $defultLogo = $helper->getDefaultLogo();
    $sellerLogo = $helper->getSellerLogo();
    $supplier = $block->getPersistentData();
    if (empty($supplier)) {
        $supplier = $helper->getCurrentSupplier();
    }
?>

    <div class="wk-supplier-company-overview-container">
        <form method="post" action="<?php echo $this->getUrl('b2bmarketplace/supplier/info_update'); ?>" id="wk-supplier-company-info-form" enctype="multipart/form-data" data-mage-init='{"validation":{}}'>
            <fieldset class="fieldset">
                <?php echo $block->getBlockHtml('seller.formkey')?>
                <?php echo $block->getBlockHtml('formkey') ?>
                <div class="field">
                    <label class="label"><span><?php echo __('Company Logo') ?></span></label>
                    <div class="control">
                        <div class="wk-logo-container">
                            <div class="wk-logo-image-block">
                                <input type="hidden" value="" name="remove_logo" id="remove_logo">
                                <label for="logo_pic">
                                    <img src="<?php echo $sellerLogo; ?>">
                                </label>
                                <input type="file" id="logo_pic" name="logo_pic" title="<?php echo __('Company Logo') ?>" class="input-text" value="" />
                            </div>
                            <div class="wk-logo-content-block">
                                <div class="wk-logo-reset"><?php echo __("Reset Logo"); ?></div>
                                <div class="wk-logo-remove"><?php echo __("Remove Logo"); ?></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="field profile">
                    <label class="label" for="banner-pic"> <?php echo __('Company Banner') ?> </label>
                    <div class="control">
                        <input type="file" id="banner-pic" name="banner_pic"  title="Banner Pic" class="banner" size="26" />
                        <div class="profileimage-set">
                            <div class="setimage">
                                <?php
                                $bannerpic = $supplier['banner_pic'];
                                if ($bannerpic && !$supplier['is_default_banner']) { ?>
                                    <img class="wk-banner" alt="<?php echo $supplier['banner_pic'] ?>" src="<?php echo $this->helper('Webkul\Marketplace\Helper\Data')->getMediaUrl().'avatar/'.$supplier['banner_pic']; ?>"/>
                                    <span class="wk-profileimagedelete" title="<?php echo __('Delete')?>">
                                        <img src="<?php echo $this->getViewFileUrl('Webkul_Marketplace::images/deleteIcon.png'); ?>" alt="<?php echo __('Delete Banner')?>" title="<?php echo __('Delete Banner')?>"/>
                                    </span>
                                    <?php
                                } else { ?>
                                    <img class="wk-banner" alt="<?php echo __('no image') ?>" src="<?php echo $this->helper('Webkul\Marketplace\Helper\Data')->getMediaUrl().'avatar/banner-image.png'; ?>"/>
                                <?php
                                } ?>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="company_name"><span><?php echo __('Company Name') ?></span></label>
                    <div class="control">
                        <input type="text" data-validate="{required:true}" id="company_name" name="wk_supplier_company_name" title="<?php echo __('Company Name') ?>" class="input-text" value="<?php echo $helper->getCompanyName(); ?>" />
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="company_tagline"><span><?php echo __('Company Tagline') ?></span></label>
                    <div class="control">
                        <input type="text" data-validate="{required:true}" id="company_tagline" name="wk_supplier_company_tagline" value="<?php echo $helper->getCompanyTagline(); ?>" title="<?php echo __('Company Tagline') ?>" class="input-text" />
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="registered_in"><span><?php echo __('Registered In') ?></span></label>
                    <div class="control">
                        <input type="text" data-validate="{required:true}" id="registered_in" name="wk_supplier_registered_in" value="<?php echo $helper->getRegisteredIn(); ?>" title="<?php echo __('Registered In') ?>" class="input-text" />
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="company_team_size"><span><?php echo __('Company Team Size') ?></span></label>
                    <div class="control">
                        <input type="text" id="company_team_size" name="wk_supplier_team_size" value="<?php echo $helper->getTeamSize(); ?>" title="<?php echo __('Company Team Size') ?>" class="input-text" />
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="certification"><span><?php echo __('Certification') ?></span></label>
                    <div class="control">
                        <input type="text" data-validate="{required:true}" id="certification" name="wk_supplier_certification" value="<?php echo $helper->getCertification(); ?>" title="<?php echo __('Certification') ?>" class="input-text" />
                    </div>
                </div>
            </fieldset>

            <fieldset class="fieldset">
                <div class="wk-fieldset-sub-title"><?php echo __("Operational Address"); ?></div>
                <div class="field required wk-country-field">
                    <label class="label" for="supplier-operational-country"><span><?php echo __("Country"); ?></span></label>
                    <div class="control">
                        <?php echo $helper->getCountryHtmlSelect($operatioanlAddress['country'], "operational_country", "supplier-operational-country"); ?>
                    </div>
                </div>
                <div class="field required wk-state-field">
                    <label class="label" for="supplier-operational-state"><span><?php echo __("State"); ?></span></label>
                    <div class="control">
                        <?php if (array_key_exists($operatioanlAddress['country'], $regions)): ?>
                            <input style="display:none;" type="text" data-validate="{required:true}" class="input-text required-entry" title="<?php echo __("State"); ?>" id="supplier-operational-state" name="operational_state" value="<?php echo $operatioanlAddress['region'] ?>">
                            <select data-validate="{required:true}" name="operational_state_id" class="input-text required-entry">
                                <?php foreach ($regions[$operatioanlAddress['country']] as $regionId => $region): ?>
                                    <?php if ($operatioanlAddress['region_id'] == $regionId): ?>
                                        <option selected value="<?php echo $regionId; ?>"><?php echo $region; ?></option>
                                    <?php else: ?>
                                        <option value="<?php echo $regionId; ?>"><?php echo $region; ?></option>
                                    <?php endif; ?>
                                <?php endforeach; ?>
                            </select>
                        <?php else: ?>
                            <input type="text" data-validate="{required:true}" class="input-text required-entry" title="<?php echo __("State"); ?>" id="supplier-operational-state" name="operational_state" value="<?php echo $operatioanlAddress['region'] ?>">
                            <select style="display:none;" data-validate="{required:true}" name="operational_state_id" class="input-text required-entry"></select>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="supplier-operational-city"><span><?php echo __("City"); ?></span></label>
                    <div class="control">
                        <input type="text" data-validate="{required:true}" class="input-text required-entry" title="<?php echo __("City"); ?>" id="supplier-operational-city" name="operational_city" value="<?php echo $operatioanlAddress['city'] ?>">
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="supplier-operational-address"><span><?php echo __("Address Line"); ?></span></label>
                    <div class="control">
                        <input type="text" data-validate="{required:true}" class="input-text required-entry" title="<?php echo __("Address Line"); ?>" id="supplier-operational-address" name="operational_address" value="<?php echo $operatioanlAddress['street'] ?>">
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="supplier-operational-postcode"><span><?php echo __("Zip/Postal code"); ?></span></label>
                    <div class="control">
                        <input type="text" data-validate="{required:true}" class="input-text required-entry" title="<?php echo __("Zip/Postcode"); ?>" id="supplier-operational-postcode" name="operational_postcode" value="<?php echo $operatioanlAddress['postcode'] ?>">
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="supplier-operational-phone"><span><?php echo __("Phone Number"); ?></span></label>
                    <div class="control">
                        <input type="text" data-validate="{required:true}" class="input-text required-entry" title="<?php echo __("Phone Number"); ?>" id="supplier-operational-phone" name="operational_phone" value="<?php echo $operatioanlAddress['telephone'] ?>">
                    </div>
                </div>
            </fieldset>

            <fieldset class="fieldset">
                <div class="wk-fieldset-sub-title"><?php echo __("Corporate Address"); ?></div>
                <div class="field required wk-country-field">
                    <label class="label" for="supplier-corporate-country"><span><?php echo __("Country"); ?></span></label>
                    <div class="control">
                        <?php echo $helper->getCountryHtmlSelect($corporateAddress['country'], "corporate_country", "supplier-corporate-country"); ?>
                    </div>
                </div>
                <div class="field required wk-state-field">
                    <label class="label" for="supplier-state"><span><?php echo __("State"); ?></span></label>
                    <div class="control">
                        <?php if (array_key_exists($corporateAddress['country'], $regions)): ?>
                            <input style="display:none;" type="text" data-validate="{required:true}" class="input-text required-entry" title="<?php echo __("State"); ?>" id="supplier-corporate-state" name="corporate_state" value="<?php echo $corporateAddress['region'] ?>">
                            <select data-validate="{required:true}" name="corporate_state_id" class="input-text required-entry">
                                <?php foreach ($regions[$corporateAddress['country']] as $regionId => $region): ?>
                                    <?php if ($corporateAddress['region_id'] == $regionId): ?>
                                        <option selected value="<?php echo $regionId; ?>"><?php echo $region; ?></option>
                                    <?php else: ?>
                                        <option value="<?php echo $regionId; ?>"><?php echo $region; ?></option>
                                    <?php endif; ?>
                                <?php endforeach; ?>
                            </select>
                        <?php else: ?>
                            <input type="text" data-validate="{required:true}" class="input-text required-entry" title="<?php echo __("State"); ?>" id="supplier-corporate-state" name="corporate_state" value="<?php echo $corporateAddress['region'] ?>">
                            <select style="display:none;" data-validate="{required:true}" name="corporate_state_id" class="input-text required-entry"></select>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="supplier-corporate-city"><span><?php echo __("City"); ?></span></label>
                    <div class="control">
                        <input type="text" data-validate="{required:true}" class="input-text required-entry" title="<?php echo __("City"); ?>" id="supplier-corporate-city" name="corporate_city" value="<?php echo $corporateAddress['city'] ?>">
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="supplier-corporate-address"><span><?php echo __("Address Line"); ?></span></label>
                    <div class="control">
                        <input type="text" data-validate="{required:true}" class="input-text required-entry" title="<?php echo __("Address Line"); ?>" id="supplier-corporate-address" name="corporate_address" value="<?php echo $corporateAddress['street'] ?>">
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="supplier-corporate-postcode"><span><?php echo __("Zip/Postal code"); ?></span></label>
                    <div class="control">
                        <input type="text" data-validate="{required:true}" class="input-text required-entry" title="<?php echo __("Zip/Postcode"); ?>" id="supplier-corporate-postcode" name="corporate_postcode" value="<?php echo $corporateAddress['postcode'] ?>">
                    </div>
                </div>
                <div class="field required">
                    <label class="label" for="supplier-corporate-phone"><span><?php echo __("Phone Number"); ?></span></label>
                    <div class="control">
                        <input type="text" data-validate="{required:true}" class="input-text required-entry" title="<?php echo __("Phone Number"); ?>" id="supplier-corporate-phone" name="corporate_phone" value="<?php echo $corporateAddress['telephone'] ?>">
                    </div>
                </div>
                <div class="actions-toolbar">
                    <div class="primary">
                        <button id="company-info" name="section" value="company_info" class="action primary" type="submit">
                            <span><?php echo __("Update Information"); ?></span>
                        </button>
                    </div>
                </div>
            </fieldset>
        </form>
    </div>

    <script id="wk-region-dropdown" type="text/x-magento-template">
        <% _.each(data, function(key, value) { %>
            <option value="<%- value %>"><%- key %></option>
        <% }); %>
    </script>

    <script>
        require([
            'jquery',
            'Magento_Ui/js/modal/alert',
            "mage/template"
        ], function($, alertBox, template) {
            var defaultLogo = "<?php echo $defultLogo; ?>";
            var sellerLogo = "<?php echo $sellerLogo; ?>";
            var warningLabel = "Warning";
            var regions = <?php echo json_encode($regions); ?>;
            $(document).ready(function() {
                var val = $(".wk-country-field select").val();
                // manageState($(".wk-country-field select"), val);
                $("body").on("change", ".wk-country-field select", function() {
                    var val = $(this).val();
                    manageState($(this), val);
                });
            });

            function manageState(currentObject, val)
            {
                var html = "";
                if (val in regions) {
                    var regionTemplate = template('#wk-region-dropdown');
                    var dropdownHtml = regionTemplate({ data: regions[val] });
                    currentObject.parent().parent().parent().find(".wk-state-field input").hide();
                    currentObject.parent().parent().parent().find(".wk-state-field select").empty();
                    currentObject.parent().parent().parent().find(".wk-state-field select").append(dropdownHtml);
                    currentObject.parent().parent().parent().find(".wk-state-field select").show();
                } else {
                    currentObject.parent().parent().parent().find(".wk-state-field input").show();
                    currentObject.parent().parent().parent().find(".wk-state-field select").hide();
                }
            }

            var acceptedImageType = ["png", "jpg", "jpeg", "gif"];
            $("body").on("change", ".wk-logo-image-block input", function () {
                var imageName = $(this).val();
                var result = imageName.split(".");
                var length = result.length;
                var currentObject = $(this);
                var ext = result[length-1];
                ext = ext.toLowerCase();
                if (acceptedImageType.indexOf(ext)!=-1) {
                    if (this.files && this.files[0]) {
                        var reader = new FileReader();
                        reader.onload = function (e) {
                            $("#remove_logo").val(0);
                            $(".wk-logo-image-block img").attr("src", e.target.result);
                            error = false;
                        }
                        reader.readAsDataURL(this.files[0]);
                    }
                } else {
                    alertBox({
                        title: warningLabel,
                        content: "<div>Invlaid image</div>",
                        actions: {
                            always: function (){}
                        }
                    });
                    currentThis.val('');
                }
            });

            $("body").on("click", ".wk-logo-reset", function () {
                $(".wk-logo-image-block img").attr("src", sellerLogo);
                $("#logo_pic").val("");
            });

            $("body").on("click", ".wk-logo-remove", function () {
                $(".wk-logo-image-block img").attr("src", defaultLogo);
                $("#remove_logo").val(1);
                $("#logo_pic").val("");
            });
        });
    </script>

enter image description here

  • Can anyone respond to this issue, its critical issue and its high priority to resolve this one. #magento2 #javascript – Jdprasad V Oct 14 at 13:45

Your Answer

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

Browse other questions tagged or ask your own question.