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>
            <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; ?>

        <?php if ($_hasAssociatedProducts): ?>
        <?php foreach ($_associatedProducts as $_item): ?>
                <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>

                        <?php endif; ?>
                     <?php endif; ?>
                <?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"
                <?php else: ?>
                    <div class="stock unavailable" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
                        <span><?= /* @escapeNotVerified */ __('Out of stock') ?></span>
                <?php endif; ?>
                <?php endif; ?>
            <?php if ($block->getCanShowProductPrice($_product)
                && $block->getCanShowProductPrice($_item)
                && trim($block->getProductPriceHtml(
                ))): ?>
                <tr class="row-tier-price">
                    <td colspan="2">
                        <?= $block->getProductPriceHtml(
                        ) ?>
            <?php endif; ?>
        <?php endforeach; ?>
        <?php else: ?>
                <td class="unavailable"
                    colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>">
                    <?= /* @escapeNotVerified */ __('No options of this product are available.') ?>
        <?php endif; ?>
<div id="validation-message-box"></div>

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

                                        <input type="text" name="name" placeholder="Veronica" class="name" required/>
                                        <input type="email" name="email" placeholder="Enter Your Email" required/>
                                        <label>Phone Number:</label>
                                        <input type="number" name="pnumber" placeholder="Enter Your Phone Number" required/>
                                        <label>Offer Amount:</label>
                                        <input type="number" name="offeramount" placeholder="Enter your Offerd Amount" required/>
                                        <input type="number" name="quantity" id="quantity" placeholder="Product Quantity" required/>
                                        <label>Message: </label>
                                        <textarea name="message" rows="4" cols="50" placeholder="Write any message here" required></textarea>
                                        <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">
                               ], function($) {

                                    alert("The paragraph was clicked.");


                                    ) {
                                        var options = {
                                            type: 'popup',
                                            responsive: true,
                                            innerScroll: true,
                                            title: '',
                                            buttons: [{
                                                text: $.mage.__('Close'),
                                                class: '',
                                                click: function () {

                                        var popup = modal(options, $('#header-mpdal'));


                                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;

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.