0

I need a solution to be able to call the products that have been added to the cart to be displayed on the homepage.

I can think of a few ways but looking for the simplest cleanest way to do it.. can anyone help?

Thanks in advance

  • Please confirm u want to add to cart a product from home page am I right? – Nagaraju K Jul 8 '17 at 16:53
0

Source: http://blog.chapagain.com.np/magento-2-get-all-shopping-cart-items-subtotal-grand-total-billing-shipping-address/

You might want to see this blog http://blog.chapagain.com.np/magento-2-get-all-shopping-cart-items-subtotal-grand-total-billing-shipping-address/. Using this code you will be able to get more than enough information of cart. And for your question to display in home page, you can do it in following way:

  1. You need to create your module, refer this link http://inchoo.net/magento-2/how-to-create-a-basic-module-in-magento-2/
  2. You need to create block class as in above blog.
  3. And a template file where you want to show cart.
  4. Easy way to show on home page is to create a block from backend and use that for a widget which shows up anywhere you desire in home page. Use this code for block creation:

    {{block class="Vendor\ModuleName\Block\BlockName" template="Vendor_ModuleName::yourcustomblock.phtml"}}

  5. If you prefer not using backend then see this answer https://magento.stackexchange.com/a/95549/51630. You need to choose one among 4 or 5.
  6. Flush magento cache, delete static-content and reindex. If any confusion let me know.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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