0

I have put together a custom product list page for special offer products. Mostly working except ive just noticed the add to cart button is failing.

Once clicked the process starts but hangs on adding... on cart button and the mini cart in top right corner just starts a spinning animation which never ends.

Everything looks fine except the UENC value is empty on the form for the product. This is currently using below code however nothing is showing:

echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED];

The add to cart code is:

<form data-role="tocart-form" action="<?php /* @escapeNotVerified */ echo $postParams['action']; ?>" method="post">
                                            <input type="hidden" name="product" value="<?php /* @escapeNotVerified */ echo $postParams['data']['product']; ?>">
                                            <input type="hidden" name="<?php /* @escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* @escapeNotVerified */ echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
                                            <?php echo $block->getBlockHtml('formkey')?>
                                            <button type="submit"
                                                    title="<?php echo $block->escapeHtml(__('Add to Cart')); ?>"
                                                    class="action tocart primary">
                                                <span><?php /* @escapeNotVerified */ echo __('Add to Cart') ?></span>
                                            </button>
                                        </form>

So the main bit going wrong seems the uenc code and action from postparams and my block not having logic for getting this data. I have botched it in using some code on phtml file to get this data however had further issues with products not redirecting to product pages if required options were present and instead just reloading the current page with the warning.

  • Post your add to cart button code – Ronak Chauhan May 8 '17 at 13:18
  • I have added into my question. – harri May 8 '17 at 13:41

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.