Hallo Josh,

Thanks a lot.
This is a good starting point.

One more question.
Where do you put your form?
It seems to me, that it shut go in shop/product.html, but how to inject it 
there?

Henri


Am Freitag, 21. November 2014 22:35:00 UTC+1 schrieb 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:
> <form method="post" id="add-cart" action="{{ item.product.get_absolute_url 
> }}">
>   {% csrf_token %}
>   <input type="hidden" id="product_id" name="product_id" value="{{ 
> item.product.id }}" />
>   <input type="hidden" name="quantity" id="id_quantity" value="1">
>   <input type="text"  class="donation" id="donation_amount" 
> name="donation_amount" />
>   <button type="submit" class="button small">Donate Now</button>
> </form>    
>
> 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 
>> <http://bitofpixels.com/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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to