0

I'm overriding grouped.phtml fileenter image description here

I add the custom button (Make an Offer) in grouped.phtml file as you can see so when I click on the button it shows me the pop-up Model as you can see in another imageenter image description here

So when I click on the submit a Question button it does not perform any action while when I tried the same scenario in simple product then it submits the data easily but in the case of grouped.phtml it do not submit the data my grouped.phtml file is

<?php $block->setPreconfiguredValue(); ?>
<?php $_product = $block->getProduct(); ?>
<?php $_associatedProducts = $block->getAssociatedProducts(); ?>
<?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>

<div class="table-wrapper grouped">
    <table class="table data grouped" id="super-product-table">
        <caption class="table-caption"><?= /* @escapeNotVerified */ __('Grouped product items') ?></caption>
        <thead>
        <tr>
            <th class="col item" scope="col"><?= /* @escapeNotVerified */ __('Product Name') ?></th>
            <?php if ($_product->isSaleable()): ?>
                <th class="col qty" scope="col"><?= /* @escapeNotVerified */ __('Qty') ?></th>
            <?php endif; ?>
        </tr>
        </thead>

        <?php if ($_hasAssociatedProducts): ?>
        <?php foreach ($_associatedProducts as $_item): ?>
        <tbody>
            <tr>
                <td data-th="<?= $block->escapeHtml(__('Product Name')) ?>" class="col item">
                    <strong class="product-item-name"><?= $block->escapeHtml($_item->getName()) ?></strong>
                    <?php if ($block->getCanShowProductPrice($_product)): ?>
                        <?php if ($block->getCanShowProductPrice($_item)): ?>
                            <?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
                            <?php //echo $block->getProductId($_item)."Sheikh"; ?>
                            <?php $priceee = $block->getProductPrice($_item);  ?>
                            <div class="Offer">
                                <button type="button" title="MakeAnOffer" class="testt" id ='btnn' style="background: #1979c3;border: 1px solid #1979c3;color: #ffffff;" >
                                    <span>Make an Offer</span>
                                </button>


                            </div>
                        <?php endif; ?>
                     <?php endif; ?>
                </td>
                <?php if ($_product->isSaleable()): ?>
                <td data-th="<?= $block->escapeHtml(__('Qty')) ?>" class="col qty">
                <?php if ($_item->isSaleable()) : ?>
                    <div class="control qty">
                        <input type="number"
                               name="super_group[<?= /* @escapeNotVerified */ $_item->getId() ?>]"
                               data-selector="super_group[<?= /* @escapeNotVerified */ $_item->getId() ?>]"
                               value="<?= /* @escapeNotVerified */ $_item->getQty() * 1 ?>"
                               title="<?= /* @escapeNotVerified */ __('Qty') ?>"
                               class="input-text qty"
                               data-validate="{'validate-grouped-qty':'#super-product-table'}"
                               data-errors-message-box="#validation-message-box"/>
                    </div>
                <?php else: ?>
                    <div class="stock unavailable" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
                        <span><?= /* @escapeNotVerified */ __('Out of stock') ?></span>
                    </div>
                <?php endif; ?>
                </td>
                <?php endif; ?>
            </tr>
            <?php if ($block->getCanShowProductPrice($_product)
                && $block->getCanShowProductPrice($_item)
                && trim($block->getProductPriceHtml(
                    $_item,
                    \Magento\Catalog\Pricing\Price\TierPrice::PRICE_CODE
                ))): ?>
                <tr class="row-tier-price">
                    <td colspan="2">
                        <?= $block->getProductPriceHtml(
                            $_item,
                            \Magento\Catalog\Pricing\Price\TierPrice::PRICE_CODE
                        ) ?>
                    </td>
                </tr>
            <?php endif; ?>
        </tbody>
        <?php endforeach; ?>
        <?php else: ?>
        <tbody>
            <tr>
                <td class="unavailable"
                    colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>">
                    <?= /* @escapeNotVerified */ __('No options of this product are available.') ?>
                </td>
            </tr>
        </tbody>
        <?php endif; ?>
    </table>
</div>
<div id="validation-message-box"></div>


<div id="header-mpdal" style="display:none;">
                                <div class="add_data">
                                    <div>
                                    <form id='sample'  method="post" action="<?php echo $block->getBaseUrl().'makeanoffer/index/save' ?>" name="insertdata">


                                        <label>Name:</label>
                                        <input type="text" name="name" placeholder="Veronica" class="name" required/>
                                        <br>
                                        <label>Email:</label>
                                        <input type="email" name="email" placeholder="Enter Your Email" required/>
                                        <br>
                                        <label>Phone Number:</label>
                                        <input type="number" name="pnumber" placeholder="Enter Your Phone Number" required/>
                                        <br>
                                        <label>Offer Amount:</label>
                                        <input type="number" name="offeramount" placeholder="Enter your Offerd Amount" required/>
                                        <br>
                                        <label>Quantity:</label>
                                        <input type="number" name="quantity" id="quantity" placeholder="Product Quantity" required/>
                                        <br>
                                        <label>Message: </label>
                                        <textarea name="message" rows="4" cols="50" placeholder="Write any message here" required></textarea>
                                        <br><br>
                                        <div class="g-recaptcha" data-sitekey="6Ld2-pMUAAAAACw-gmlZlpvYLWpWfWqbgykbZHq3"></div>
                                        <script src='https://www.google.com/recaptcha/api.js'></script>
                                        <script src='https://www.google.com/recaptcha/api.js?hl=es'></script>

                                              <input class="form-submit" type="Submit"
                                                 value="Submit a question">
                                    </form> 
                                    </div>
                                </div>
                            </div>
                            <script>
                               requirejs([
                                   'jquery'
                               ], function($) {

                                    $(".btnclik").click(function(){
                                        alert($('.name').val());
                                    alert("The paragraph was clicked.");
                                  });


                               })
                            </script>

                            <script>
                                require(
                                    [
                                        'jquery',
                                        'Magento_Ui/js/modal/modal'
                                    ],
                                    function(
                                        $,
                                        modal
                                    ) {
                                        var options = {
                                            type: 'popup',
                                            responsive: true,
                                            innerScroll: true,
                                            title: '',
                                            buttons: [{
                                                text: $.mage.__('Close'),
                                                class: '',
                                                click: function () {
                                                    this.closeModal();
                                                }
                                            }]
                                        };

                                        var popup = modal(options, $('#header-mpdal'));
                                        $(".testt").on('click',function(){ 
                                            $("#header-mpdal").modal("openModal");
                                        });

                                    }
                                );

                                function double(){
                                    // alert("The Asad Khan.");
                                    var x = document.getElementById("quantity").value;
                                    var y = document.getElementById("price").value;
                                    // console.log(x);
                                    // console.log(y);
                                    document.getElementById("product_price").value = x * y;
                                }
                            </script>


from header-mpdal my form starts

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.