0

I working on e-commerce website using Satchmo. However, there are few customization required for my store.

  1. While ordering a product I should be able to specify a delivery date (shipping date).
  2. There can be only 20 (max_num_delievries) deliveries possible per day for a product. If number of deliveries for a particular date for a particular product exceeds 'max_num_delievries', user should not be able to select that date while ordering the product.

Can someone please help in this and guide me how to achieve this using Satchmo?

Thanks in advance..

vnayak01
  • 11
  • 3

1 Answers1

0

I would try something like this:

1) create a local app (eg. delivery_date) with a model like "DeliveryDate" or so. For example localsite/delivery_date/models.py:

class DeliveryDate(models.Model):
    product = models.ForeignKey(Product)
    date = models.DateField()
    order = models.ManyToManyField(Order)

    class Meta:
        unique_together = ("product", "date")

2) the validation of the max 20 existing orders... mhh, good question, maybe the best would be, to do it on the form? Override the clean method and check if this delivery date is associated with 20 orders already... maybe something like localsite/delivery_date/forms.py

class DeliveryDateForm(forms.ModelForm):
    class Meta:
        model = DeliveryDate

    def clean(self):
        super(DeliveryDateForm, self).clean()
        ... check here the order_set count

... but maybe the form isn't the best place to do this.

You also probably want to hide and auto-set the initial values for product and order yourself, and the user only being supposed to select a date.

3) Regarding satchmo... I would use signals to react after a product has been added to the cart (there is a signal just for this case), and add a listener which redirects the user to a view where he can select the date for this product. Look at the example here with the signal "cart_add_view": http://www.facebook.com/note.php?note_id=101466134049

Maybe ajax would be a good option here. With a hidden container in your page... which shows up after adding a product to the cart (only if the product hasn't already a DeliveryDate associated to this order/product), and asking the user to select a date.

This whole stuff would be on the listener: check if the product needs a delivery date, and if yes, send an ajax response to pop-up the window, and put in the repsonse-context the form, with the initial product and order hidden fields.

And to save the delivery-date you will need another ajax-view.

Well it's merely an idea how I would try to do it ;-) It will probably need adjustments here and there, of course. But hopefully it helps you further.

Regards, Andrea

andzep
  • 1,877
  • 24
  • 35