Limit product quantity to 1 per customer in magento - php

I need to limit the quantity of a product purchased by a customer to 1 per day. We are going to have something like deal and day and targeting consumers. We do not want some one to buy high quantities. Could some one guide me as to what the general approach should be to do this? Thanks.
I noticed that there is a table sales_flat_order_item which contains products_id for an order, a join of this table with sales_flat_order should give me product_id for the orders placed by the customer. How do i access this table data directly and perform the join operation the magento way? Do i need to create a new module? or modify a existing module?

You could just create a coupon/coupons for this. Leave the product at the original price and hand out a coupon to the targeted customers. Make sure that you set it to "only applies to 1 item" and can only be used once.
Regards,
Kenny

Related

MySQL DB design for a products rental with pricing history

I'm designing a database for product rental. I'm using Laravel 8 framework.
prices change all the time.
The rental order requires a quote generated by the client.
The prices are stored but not listed in the user view, they are only for reference in the admin order quote generator view.
The client wants to be able to change the price for each quote before sending it as their specific client may need special treatment.
So, summing up, I need:
To store a record for the price of a specific order quote.
To store a base price and a history record of this price.
To be able to list the available products in between two dates filtered by the status of the order, which will change until the final approval of the quote. Also filtered by the stock available.
Have additional costs associated to the specific order.
Different total price for deferred payment.
This is what I came up to, I have a table for:
Orders
Products
Order_Product (this name format is required by laravel's eloquent)
Products_Prices
Additionals
Orders_statuses
In the order_product table I'm planning to store the price defined for the client, and the count of rented products. Also foreign keys for a many-to-many between products and orders.
In the order I'm planning to store the "pickup" and "return dates to query first WHERE "orders with approved status" BETWEEN the two dates selected by the user. Finally get order_products with a NOT IN to display the available products.
The products_prices table I use it to store the changes record.
In the products table I have availability because the product may not be available for rent for many reasons for a period. Stock and colors that I will use for ordering the list because of a requirement from the client so I go first for primary color, secondary and tertiary afterwards.
I'm not sure if this is the most efficient way to achieve what I'm looking for. Since I will need to check products availability all the time I need to be sure that this is the fastest and more reliable one.
I'm not english speaker so I feel the need to clarify this:
The client = My client.
User = My client's client.
Thanks in advance!

CS Cart Specific price per user group

Is it possible to add second price to each product and use that price if user in specific usergroup?
I was thinking doing that by adding another column to the product price table and then take advantage of the promotion function to somehow use that price instead of the usual discount you can set from admin.
Any pointers or ideas would be great, thank you.
Yes, it is possible to define price for product that is valid/shown only for users in specific usergroup.
To achieve this you need to use Quantity discounts tab on Editing product page.
Name of this tab implies as there must be some large amount of items bought (like volume discounts...), but quantity can also be just 1 item.
For this you first need to define usergroup (Customers->User groups).
Example is shown also on CS-Cart Knowledge base: Wholesale Prices
Best regards,
Bostjan
It is default CS-Cart feature. Please check the following article in the database:
http://kb.cs-cart.com/wholesale-prices

How to store complex product/order data in MySQL?

I'm working on an order system for my online shop. I have 2 tables:
products, storing info about products
orders, storing general id's & infos of customer orders.
Now I want to have a way to store complex customer orders in the database. I need something that will let me know how much of each size (S, M or L) of each product is in an order.
The tricky part is that I want to be able to add/edit/delete products (of course without affecting orders from the past), so the method should be flexible
How should I go about this?
a separate table for every order, with products as rows?
one table for all orders, with products as columns?
some other option?
Thanks!
Depends on your goals for your cart. For instance, do you want to allow guest purchases? i.e. where a user does not need to login in order to make a purchase?
The attached image is a design I have been working on and it goes like this:
A visitor selects products from the site and adds these to a session cart (just a place to temporarily store the products, their quantities and their prices etc.)
Once the customer is ready to check out, we create the order, the order person and the person_address (where the product must be delivered to) and add the items to the order_item table. All this information is added by the customer in the checkout page.
The final step is then to offer the payment methods: paypal, credit card, etc.
What I like about this design is that users have no obligation to register with us. Order_person acts as a kind of interface between users and orders. If do register, we simply link order_person to the user table...
I have included a sample front end of the checkout page too.
At the very least you need:
Products (one row per product)
ProductID
Size
Orders (one row per order)
OrderID
OrderDetails (one row per product per order)
ProductID
OrderID
Size
Note that each 'size' is its own ProductID. You'll probably want to have yet another ID that groups products that are the same 'base' product, but in different sizes.
So if Order #1 has three products, and Order #2 has four, then OrderDetails will have seven rows:
OrderID ProductID Quantity
1 234 2
1 345 9
1 456 30
2 432 1
2 234 65
2 654 8
2 987 4

Auto switch customer group in magento

Has anyone found a way to auto switch a customer group based on specific rules? For example, if a customer over their lifetime has ordered 200 plus bottles of something they are grouped in a specific customer tier and get special pricing (wholesale type situation)
I know how to do segments of customers but that doesn't help me auto change which customer group they belong too.
Thanks in advance for any help in the right direction...
there are a couple of payable extensions at magento connect or you can create simple module with custom actions. Article for a good start.
In case someone is still looking for an answer, this extension (which I created) can do exactly what you are looking for and more out of the box:
Website:
https://plugin.company/magento-extensions/automatic-customer-group-switching.html
On Magento Connect:
http://www.magentocommerce.com/magento-connect/automatic-customer-group-switching-by-plugin-company.html
If you'd like to build your own custom functionality though, I'd recommend looking into the sales_order_placed_after event and getting the order history details by filtering an order collection on the customer ID that has placed the order.
Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id', $yourCustomerId);
You can then loop through each order and get all items by using the getAllItemsmethod.
Alternatively you could retrieve a sales_order_item collection, and join the corresponding order details from the sales_flat_order table. Then you could filter on customer ID and product ID and group the results on product ID.
You can then base your customer group switching logic on the sum of the total ordered product quantity.

System of offers with multiple offers and products

I am developing a system of offers and I came up with the following problem:
If I have an offer that buying the "product A" and "Product B" I paid 10% less, I can register as a new offer such a product like Coke, putting the price discounting 10%, ok, but the problem is, if the user select the product A and product B I want to convert it to a discount, ie, selecting the products that generate the discount, the user takes the discount.
My solution is:
I could make a table with the products and set the type of product as normal and promotion, if the type of product is promotion, will have a table associated with the products (in this case the product A and product B), but If I have 10 offers, I need to verify each product to ensure it participates in the promotion, I think soo slow.
Sorry my English, if you don't understand me, leave a comment. thanks!
Setup the products table as normal. Then set up a special offers table and a table for the products included in each offer.
Products Table
product_id
product_name
Offers Table:
offer_id
percent_off
Products_In_Offer Table
offer_id
product_id

Categories