I working on e-commerce website using Satchmo. However, there are few customization required for my store.
While ordering a product I should be able to specify a delivery date (shipping date).
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..
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
Related
I'm starting to get the hang of NetSuite but this one has stumped me. I am looking for a way to update the line items on an order from a workflow in NetSuite. From what I can tell it doesn't seem to expose those fields, is there any way around this?
I have a saved search returning all of the transaction line items that I want modified, there is a field on the Sales Order Line Item called "Create Fulfillment Order". It shows up under saved searches as "Create Fulfillment Order Column", but when I add an action to a workflow to set the field value, the only fields that show up are Sales Order fields. Is there any way to access the Sales Order Column fields, since that's really what's being returned by my saved search anyways.
I've looked at the Sub Types defined in the workflow to see if there's one for Sales Order Item or anything but there's not, just Sales Order. Any help would be greatly appreciated, thanks in advance!
There's nothing built-in that will let you access transaction line items from a workflow. You'll need to use SuiteScript to create a custom workflow action. Then you can call that action from your workflow.
I have a specific question regarding the utilization of three tables in a database. Table 1 is called Personnel, and lists the names of the staff.
Tables 2 and 3 are identical, just listing two different types of overtime (long and short), along with the hours of the OT, Date of the OT, and Assigned to/Picked fields that are empty.
Here is the idea, I just dont know how to implement it. I would like to create a form for people to enter their OT picks, then automatically move to the next person on the list. So Rich Riphon, as an example, would be up first, would click on the link I would send, and a form would open up, showing his name, populated by the first table, and showing two drop down menus, populated from the Long OT and Short OT tables. He would select one from each (or None, which would be a option) and Submit it.
The form action would be to place his name in the Assigned field for the OT he picked, and place a Yes in the Picked field.
When the next person in the list opens the form, it has moved down to number 2 on the Personnel list, Cheryl Peterson, and shows her the remaining OT selections (excluding those that have a Yes in the Picked column).
Any suggestions or comments or better ways to do this would be appreciated.
First, I don't think ms access would be able to (easily) kick off the process based on a hyperlink. You may be able to do something by passing a macro name to a cmd prompt but it would take some mastery to get it working properly. Could you instead create a login form to get the current user? If you do that you don't really need to display the personnel list, just keep track of who has not yet responded to the OT request. Essentially at that point all you would need on your form is a listing of the available OT and a button that creates the assignment. Also it may be easier (and a better design) to only have one table for the OT listings and add a column for the type of overtime (long/short).
What if Cheryl isn't the 2nd person to get the form? Your concept goes out the window.
Instead, I would keep a table of all user names, and their security level. managers can see everything, individual users can only see their record. This would be done by using a query behind the OT Picks form, and either filtering by the current user or not filtering at all. I have done many of these types of "user control" databases and they all have worked well.
As for the actual OT tracking, I agree with Steve's post in that it should be done in one table This would be the preferred method of a concept referred to as "normalizing data". You really want to store as little data as possible to keep the size of your database down. As an example, your Login table would have the following fields:
UserID
FirstName
LastName
SecurityLevel
Address1
Address2
City
State
Phone
Etc... (whatever relevant info pertains to that person)
Your OT table would look like this:
UserID
OTDate
OTHours
OTType
Etc... (whatever else is relevant to OT)
You would then join those 2 tables on the UserID fields in both tables any time you needed to write a query to report OT hours or whatever.
I have one form using to different models. I want to be able to create a new Person and eventually a new User, to give this person an account. A person doens't need to have a User related (could be just a person used for statistics or something like that). I have a checkbox in my form "Click if you want create a user" and I show the user part of the form if it's checked.
Then in the controller I can, with the checkbox value, know if I need call performAjax() for both Person and User or only Person.
But my problem is about the client validation. If I try to submit the form without the User required field, for example, the submition will abort and i'll get some errors like "This field is requiered".
So, my question is how could I skip the validation of my user model if its fields are empty (checkebox unchecked, we don't want to create a user).
Any help are welcom :)
Sorry for my bad English.
Have a good day :)
Michaƫl S.
When saving the model, set the first parameter on false to skip validation:
$model->save(false)
I need to do the stock management website with 2 Content type Supplier and Product. First I add contents in Supplier content type. Then I add node reference field in Product content type and call it supplier and make it multiple value. it's looks good, i can select suppliers and save it. but in my concept i need to check which supplier sale this product and how price. so i need to add suppliers and price in the same form like my image.
the propose of this form, user can check how price of each supplier for this product and they can choose the lowest price for purchase in the next process.
Guys, did you have the idea that i can do like this ?
Based on your image attached, I'd assume you have Druapl 7.
You can do this by installing Field Collection module. To get the table-input, install Field Collection Table.
Core Fields can have multiple instances of the same field. But you can't group them and make the whole group a multi-instance group.
Drupal 6 required CCK module to have fields, and there was a MultiGroup module (CCK 3branch which never had a stable release) that does the similar for Drupal 6.
Although OP will not need this, dear Googler if you are looking for a simple table with text fields, try TableField module
This is propably a simple task to solve in Symfony2 but I am really stuck here:
I am building a very simple shop. There are three entities: Products, Customers, and Orders. The last one contains three columns: customer_id, product_id, and quantity. The shop simply consists of a page listing all the products with a select field for each to chose the quantity, followed by a form to enter your customer data.
I have no problem creating the form for the customer data nor listing the products itself (without the select fields).
But how do I create a form including the select fields of the products, which then should become order entities?
I played around with form collections and I do understand all the given examples with adding tags to an entity etc. But I can't get the hang of how to adjust it to my situation.
What I have in mind goes something like this:
// Create new customer
$customer = new Customer();
// At this point, create form and validate it.
// Having trouble here, need a hint to get it right.
...
// If form is ok, loop thru all the products.
// Since I do not know yet how to define the form,
// I don't know yet what to loop over, too.
foreach( ..... ){
if($quantity > 0){
$order = new Order();
$order->setQuantity($quantity);
$order->setProduct($product);
$customer->addOrder($order);
}
}
// then persist $customer, cascading its orders.
...
I have been spending hours on this. Any help is greatly appreciated. Thanks!
Update:
Eventually I got it working. I created an OrderFactory and a OrderFormType and had to change around the whole setting a bit. The AcmePizzaBundle which is mentioned in the responses below was actually a great help to get the missing parts right.
Take a look at an example: AcmePizzaBundle.
It has 4 entities you need: Pizza, Order, OrderItem, Customer.