[mezzanine-users] Re: Cart processors

2014-11-21 Thread Josh B
At first glance this seems like a pretty good approach.

On Sunday, November 16, 2014 9:56:11 PM UTC-7, Alex Hill wrote:
>
> Hi all,
>
> Currently discounts, tax and shipping are all dealt with in their own 
> separate handlers, and handled slightly differently from one another. I'd 
> like to unify these into a more flexible system of "cart processors", 
> objects which provide methods to modify the entire cart and each line item. 
> Whenever the cart is modified, the line items and cart totals are 
> recalculated by calling each of the cart processors in sequence. Think of 
> it like middleware for shopping carts.
>
> A new setting would be introduced to define the list of processors that 
> should be run.
>
> The main point of this is to make it easier to define your own discount 
> systems - cases like "free shipping for orders over $50" or "buy any two of 
> this group of products and get a third free" or "registered users get 10% 
> off" can't be implemented using the current discount system, and defining 
> your own is pretty messy. If tax and shipping can be implemented under a 
> system like this, it should simplify Cartridge's code in a few places as 
> well.
>
> django-shop implements this as "cart modifiers" – check out the API at 
> https://github.com/divio/django-shop/blob/master/shop/cart/cart_modifiers_base.py
> .
>
> Looking for general feedback, use cases, and any concerns or issues anyone 
> can see with a system like this.
>
> Cheers,
> Alex
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Re: Cartridge creating a product with a user defined price

2014-11-21 Thread Josh B
Sorry, was traveling and missed your message. What you will need to do is 
create either a view or a page processor 
(http://mezzanine.jupo.org/docs/content-architecture.html#page-processors) 
to post your new form to. Code samples below.

Here is my form:

  {% csrf_token %}
  
  
  
  Donate Now


Form processing code:
from .utils import Donation

if request.method == "POST" and form.is_valid():
  product = Product.objects.get(id=request.POST.get("product_id"))
  item = Donation(product, 
float(request.POST.get("donation_amount","0.0")) )
  request.cart.add_item(item, 1)

Utils
class Donation(object):
def __init__(self, product, unit_price, buyers_group):
product_variation = product.variations.all()
self.description = product.title
self.unit_price = unit_price
self.url = product.get_absolute_url()
self.sku = product_variation[0].sku
self.product = product
self.image = product_variation[0].image
self.buyers_group = buyers_group

def price(self):
  return self.unit_price 

def __unicode__(self):
return self.description

On Friday, November 21, 2014 2:20:29 PM UTC-7, henri wrote:
>
> Hallo,
>
> I still don't know really how to start.
> Is the implementation similar to what Josh Cartmell describes in his Blog 
> Collecting 
> additional information on a per product basis in Cartridge 
> 
> ?
>
> Henri
>
>
> Am Dienstag, 18. November 2014 19:22:01 UTC+1 schrieb henri:
>>
>> Hallo Josh,
>>
>> I also need the Donation option for real products, so I think your 
>> approach ist the right for my case.
>>
>> I must say, I'm not only new with Mezzanine/Cartrige but also with 
>> Django/Python.
>> Before I was mainly coding in PHP.
>>
>> So I tried to understand your code and find a way to implement it, but I 
>> think I'm not able to.
>> I think it is somehow connected with shop/views.py but I have no idea how.
>>
>> Maybe you can give me some hints,
>>
>> Henri
>>
>>
>>
>> Am Dienstag, 18. November 2014 00:03:54 UTC+1 schrieb Josh B:
>>>
>>> This approach has been solid for me and currently using it in a 
>>> production environment. For my use I needed real Donation products as they 
>>> needed to expire or only sell a limited number. If you don't need that 
>>> functionality then you can use what Josh C posted.
>>>
>>> Josh
>>>
>>> On Monday, November 17, 2014 4:56:44 AM UTC-7, henri wrote:

 Hey Josh,

 I also would like to implement donation driven products.
 Do you still stay with this approach or have you found a better 
 solution?

 Henri 



-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Re: Cartridge creating a product with a user defined price

2014-11-21 Thread henri
Hallo,

I still don't know really how to start.
Is the implementation similar to what Josh Cartmell describes in his Blog 
Collecting 
additional information on a per product basis in Cartridge 

?

Henri


Am Dienstag, 18. November 2014 19:22:01 UTC+1 schrieb henri:
>
> Hallo Josh,
>
> I also need the Donation option for real products, so I think your 
> approach ist the right for my case.
>
> I must say, I'm not only new with Mezzanine/Cartrige but also with 
> Django/Python.
> Before I was mainly coding in PHP.
>
> So I tried to understand your code and find a way to implement it, but I 
> think I'm not able to.
> I think it is somehow connected with shop/views.py but I have no idea how.
>
> Maybe you can give me some hints,
>
> Henri
>
>
>
> Am Dienstag, 18. November 2014 00:03:54 UTC+1 schrieb Josh B:
>>
>> This approach has been solid for me and currently using it in a 
>> production environment. For my use I needed real Donation products as they 
>> needed to expire or only sell a limited number. If you don't need that 
>> functionality then you can use what Josh C posted.
>>
>> Josh
>>
>> On Monday, November 17, 2014 4:56:44 AM UTC-7, henri wrote:
>>>
>>> Hey Josh,
>>>
>>> I also would like to implement donation driven products.
>>> Do you still stay with this approach or have you found a better solution?
>>>
>>> Henri 
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Re: Cartridge creating a product with a user defined price

2014-11-21 Thread henri
I still don't know really how to start.
Is the implementation similar to what Josh C discuss in his Blog Storing 
custom fields on OrderItem 

?

Henri

Am Dienstag, 18. November 2014 19:22:01 UTC+1 schrieb henri:
>
> Hallo Josh,
>
> I also need the Donation option for real products, so I think your 
> approach ist the right for my case.
>
> I must say, I'm not only new with Mezzanine/Cartrige but also with 
> Django/Python.
> Before I was mainly coding in PHP.
>
> So I tried to understand your code and find a way to implement it, but I 
> think I'm not able to.
> I think it is somehow connected with shop/views.py but I have no idea how.
>
> Maybe you can give me some hints,
>
> Henri
>
>
>
> Am Dienstag, 18. November 2014 00:03:54 UTC+1 schrieb Josh B:
>>
>> This approach has been solid for me and currently using it in a 
>> production environment. For my use I needed real Donation products as they 
>> needed to expire or only sell a limited number. If you don't need that 
>> functionality then you can use what Josh C posted.
>>
>> Josh
>>
>> On Monday, November 17, 2014 4:56:44 AM UTC-7, henri wrote:
>>>
>>> Hey Josh,
>>>
>>> I also would like to implement donation driven products.
>>> Do you still stay with this approach or have you found a better solution?
>>>
>>> Henri 
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.