I don't think I did have a corresponding Product.  SelectedProduct (which
Cart and Order Items inherit from) is only loosely coupled to actual
Products, there's no ForeignKey, SelectProduct just keeps a copy of the
sku.  In my case I just gave the CartItem the sku "DONATION-[the amount
donated]"

It's been a long time since I did this so it's possible things have changed
and this won't work anymore, but glancing over the codebase it seems like
it should still work.

On Mon, Nov 10, 2014 at 11:23 PM, Josh B <josh.batche...@wearetopsecret.com>
wrote:

> Nice, you also had to create a corresponding product, right?
>
> On Monday, November 10, 2014 10:12:41 AM UTC-7, Josh Cartmell wrote:
>>
>> Hey Josh, that seems like a pretty good way to handle it.  I had once
>> dealt with allowing users to make donations to a site with Cartridge (not
>> purchasing products for the donation, just straight donations) and did this:
>>
>> def add_donation_item(cart, price, notes=None):    """    Adds a donation to 
>> the cart.  donation is a product variation    """    item, created = 
>> cart.items.get_or_create(sku=("DONATION-%s" % price), unit_price=price)    
>> if created:        item.description = "$%s Donation" % price        
>> item.unit_price = price        item.url = "/shop/donate/"        item.notes 
>> = notes    else:        item.notes += notes    item.quantity += 1    
>> item.save()
>>
>> In my case I didn't create a particular Donation objects, but I think
>> doing that makes things nicer/saner and I think it's a good approach.
>>
>> On Sun, Nov 9, 2014 at 1:18 AM, Josh B <josh.ba...@wearetopsecret.com>
>> wrote:
>>
>>> I am creating a store that has normal products and it also has donation
>>> based products. With the donation products the user defines the price.
>>>
>>> Here is where I am at so far and want to see if someone else has a
>>> better idea.
>>>
>>> I created an add_donation function that loads in the product details and
>>> creates a new Donation object where I set the price to the user defined
>>> price. This feels a little hacky to me but this might be the easiest way.
>>> Thoughts?
>>>
>>> https://gist.github.com/joshbatchelor/dc093ff99b129297d488#file-
>>> gistfile1-txt
>>>
>>> Thanks.
>>>
>>> --
>>> 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-use...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> 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.
>

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

Reply via email to