1

I am experiencing an issue with the recently ordered block which is positioned on category pages in Magento 2.2.

After the customer orders products, they should show in this block as a list of recently ordered items.

They show normally, but without the add to cart button

enter image description here

All of the products are in stock and enabled.

By default the Magento_Sales/templates/reorder/sidebar.phtml template is used to show this block.

This piece of code makes the Add to cart button show or not:

<div class="primary no-display"
    data-bind="css: {'no-display': !lastOrderedItems().isShowAddToCart}">
    <button type="submit" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>" class="action tocart primary">
        <span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
    </button>
</div>

Seems that !lastOrderedItems().isShowAddToCart returns true...I'm just not sure why.

There is no display: none property which is out of place. The no-display class gives it the display: none property. And this class depends on the result of !lastOrderedItems().isShowAddToCart.

As far as I can see, this is in Luma theme also in default Magento 2.2, but it is bypassed by Luma's additional css (display: block is added to this element with custom css).

Since this is basically default Magento 2.2 code, what am I missing? Is this a default bug or?

  • I could not reproduce the case you are talking about. It seems like some of the products are not saleable. – Purushotam Sangroula Nov 29 '17 at 8:11
  • I would recommend you to inspect the add to cart button and div surrounding it. Check the css as well, there might be display:none for that dom element. – Purushotam Sangroula Nov 29 '17 at 8:14
  • There is no display:none which is out of place. The no-display class gives it the display:none css property. And this class depends on the result of !lastOrderedItems().isShowAddToCart. As far as I can see, this is in Luma theme also, but it is bypassed by additional ccs (display:block is added to this element). – Lez Dec 13 '17 at 10:10

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.