Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save blopa/eb8b0b568e37e7666adcb1b82a370af4 to your computer and use it in GitHub Desktop.

Select an option

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"
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