Frontend.services
  • Frontend development
  • Quick Code
Select Page

Clear the cart before adding new product in Craft Commerce

by matotominac | Jun 25, 2018 | Quick Code | Craft CMS, Craft Commerce

class PluginNamePlugin extends BasePlugin { public function init() { // Clear cart before new product is added craft()->on('commerce_cart.onBeforeAddToCart', function($event){ $cart = craft()->commerce_cart->getCart();...

Programmatically Create New Category in Craft CMS

by matotominac | Apr 5, 2018 | Quick Code | Craft CMS, plugin development

// First we create empty category model $newCategory = new CategoryModel(); // Now we assign our new category to category group. // You can find category group id inĀ /admin/settings/categories. $newCategory->groupId = $categoryGroupId; // Give our new category a...

Recent Posts

  • Clear the cart before adding new product in Craft Commerce
  • Programmatically Create New Category in Craft CMS

Archives

  • June 2018
  • April 2018

Categories

  • Quick Code