Hi Josh, thx for your reply!
Sorry for the confusion. What (and how) I'm trying to do is to calculate
the shipping by location with the shipping_detail_country (works good) from
the order_form AND the product custom shipping class and fields that I
injected in the product model and the admin.
I git cloned the cartridge.shop 0.9.5 to have it locally as an app under
the name cucashop (that way I can modify the models and stuff I need; I'm
happy with the version and won't need an update)
Added a custom shipping model:
In *cucashop.models.py *
class ProductShipping(models.Model):
COUNTRIES = (
('CA', _('Canada')),
('US', _('United States of America')),
Country = models.CharField(choices=COUNTRIES, max_length=100)
Cost = fields.MoneyField(_("Cost of 1 item"))
with_another_item = fields.MoneyField(_("extra cost with another item"))
product = models.ForeignKey("Product", related_name="shipping")
def __unicode__(self):
return self.Country
In *cucashop.admin.py*
################
# SHIPPING #
################
class ProductShippingAdmin(TabularDynamicInlineAdmin):
model = ProductShipping
##############
# PRODUCTS #
##############
...
class ProductAdmin(DisplayableAdmin):
...
inlines = (ProductImageAdmin, ProductShippingAdmin,
ProductVariationAdmin)
Basically trying to add customs shipping fields by product in the admin.
This works great.
Now the *problem*:
How can I have access to the product instance and this new shipping class
in my custom *checkout.py* custom_billship_handler from the cart?
That way if I have a user buying a product and selecting "Canada" in the
shipping form, I can calculate or show the cost for that product with this
location.
If that helps I also posted the code here
https://bitbucket.org/buddweeze/test-shipping-cartridge/overview
Many thanks, let me know if this makes more sense or if a better approach
could be suggested.
On Thursday, October 2, 2014 7:31:42 AM UTC-7, Josh Cartmell wrote:
>
> Hey Mat, could you go into more detail about what you mean by "location +
> category". I'm not sure what you are trying to do so it's hard to make a
> recommendation =)
>
> On Wed, Oct 1, 2014 at 12:11 PM, Mat Caissy <[email protected]
> <javascript:>> wrote:
>
>> Hey everyone,
>>
>> After browsing on the forum, I successfully setup a custom
>> billship_hander depending on the country from the order_form
>>
>> SHOP_HANDLER_BILLING_SHIPPING = "myapp.checkout.custom_billship_handler"
>>
>> def custom_billship_handler(request, order_form):
>>
>> if order_form is not None:
>> if not request.session.get("free_shipping"):
>> settings.use_editable()
>>
>>
>> if order_form.cleaned_data["shipping_detail_country"] ==
>> "Canada":
>> set_shipping(request, "CanadaPost Regular", 5.00)
>>
>>
>> elif order_form.cleaned_data["shipping_detail_country"] ==
>> "US":
>> set_shipping(request, "CanadaPost US Regular", 7.90)
>>
>>
>> else:
>> set_shipping(request, _("Flat rate shipping"), settings.
>> SHOP_DEFAULT_SHIPPING_VALUE)
>>
>>
>>
>> But now, is there a way to filter my shipping by location + category, or
>> product type as defined in my child_categories ?
>>
>> I've been trying with the cart and order instance, but it doesn't work:
>>
>> #cart = Cart.objects.from_request(request)
>> #cart_test = request.cart.has_items()
>> #order = Order.objects.from_request(request)
>>
>> Any tips is appreciated! 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 [email protected] <javascript:>.
>> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.