0

im trying to create new button in shipping multiple addresses page. When i open addresses.phtml, there's so much button like in code below.

 <div class="actions-toolbar">
        <div class="primary">
            <button type="submit" title="<?php /* @escapeNotVerified */ echo __('Go to Shipping Information') ?>" class="action primary continue<?php if ($block->isContinueDisabled()):?> disabled<?php endif; ?>" data-role="can-continue" data-flag="1"<?php if ($block->isContinueDisabled()):?> disabled="disabled"<?php endif; ?>><span><?php /* @escapeNotVerified */ echo __('Go to Shipping Information') ?></span></button>
        </div>
        <div class="secondary">
            <button type="submit" data-multiship-item-update="" class="action update" data-role="can-continue" data-flag="0"><span><?php /* @escapeNotVerified */ echo __('Update Qty &amp; Addresses') ?></span></button>
            <button type="button" title="<?php /* @escapeNotVerified */ echo __('Enter a New Address') ?>" class="action add" data-role="add-new-address"><span><?php /* @escapeNotVerified */ echo __('Enter a New Address') ?></span></button>
            <a href="<?php /* @escapeNotVerified */ echo $block->getBackUrl() ?>" class="action back"><span><?php /* @escapeNotVerified */ echo __('Back to Shopping Cart') ?></span></a>
        </div>
 </div>

And that submit will send form to AddressesPost.php which got code like below.

public function execute()
    {
        if (!$this->_getCheckout()->getCustomerDefaultShippingAddress()) {
            $this->_redirect('*/checkout_address/newShipping');
            return;
        }
        try {
            if ($this->getRequest()->getParam('continue', false)) {
                $this->_getCheckout()->setCollectRatesFlag(true);
                $this->_getState()->setActiveStep(State::STEP_SHIPPING);
                $this->_getState()->setCompleteStep(State::STEP_SELECT_ADDRESSES);
                $this->_redirect('*/*/shipping');
            } elseif ($this->getRequest()->getParam('new_address')) {
                $this->_redirect('*/checkout_address/newShipping');
            } else {
                $this->_redirect('*/*/addresses');
            }
            if ($shipToInfo = $this->getRequest()->getPost('ship')) {
                $this->_getCheckout()->setShippingItemsInformation($shipToInfo);
            }
        } catch (\Magento\Framework\Exception\LocalizedException $e) {
            $this->messageManager->addError($e->getMessage());
            $this->_redirect('*/*/addresses');
        } catch (\Exception $e) {
            $this->messageManager->addException($e, __('Data saving problem'));
            $this->_redirect('*/*/addresses');
        }
    }

Like in the code above, there's getParam() which i though that the button send data and the code getParam will know what button did we clicked. But i can't find where or when did the button send data. So my question, how could the code know which button we clicked?

1 Answer 1

0

Look inside:

vendor/magento/module-multishipping/view/frontend/web/js/overview.js

The option is:

placeOrderSubmit: 'button[type="submit"]'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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