Skip to content
Browse files

Created rendering context for the cart cms plugin

Added .gitignore to source control
  • Loading branch information...
1 parent fb680ed commit 4c5532b9d7b30c29e926c40515aa95f24df2454c @chrisglass committed
Showing with 14 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +11 −0 cmsplugin_shop/cms_plugins.py
View
3 .gitignore
@@ -0,0 +1,3 @@
+.project
+.pydevproject
+*.pyc
View
11 cmsplugin_shop/cms_plugins.py
@@ -1,5 +1,7 @@
+from cms.models.pluginmodel import CMSPlugin
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
+from shop.util.cart import get_or_create_cart
class CartCMSPlugin(CMSPluginBase):
model = CMSPlugin
@@ -7,6 +9,15 @@ class CartCMSPlugin(CMSPluginBase):
render_template = "cmsplugin_shop/cart.html"
def render(self, context, instance, placeholder):
+ request = context['request']
+ cart = get_or_create_cart(request)
+ cart_items = cart.items
+
+ context.update({'cart':cart})
+ context.update({'cart_items':cart_items})
+
return context
+
+
plugin_pool.register_plugin(CartCMSPlugin)

0 comments on commit 4c5532b

Please sign in to comment.
Something went wrong with that request. Please try again.