Last active
April 25, 2026 19:06
-
-
Save blopa/eb8b0b568e37e7666adcb1b82a370af4 to your computer and use it in GitHub Desktop.
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function getCartItemCount() | |
| { | |
| if (!$this->isModuleEnabled()) { | |
| return 0; | |
| } | |
| $quote = $this->cart->getQuote(); | |
| return (int)$quote->getItemsQty(); | |
| } | |
| public function addItemToCart($productId, $qty = 1) | |
| { | |
| if (!$this->isModuleEnabled()) { | |
| return ['success' => false, 'message' => 'GameShop is disabled.', 'cart_count' => 0]; | |
| } | |
| // Normal add-to-cart logic here | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment