Statistics for people's shoppings - statistics

I am building some project (website) on people's shopping (stuff stored in refrigerator) . I need to generate an automatic shopping cart based on people's shopping .
For example if some person buys every week one bottle of milk , than the website will offer the person to buy milk once a week (if there is no milk in refrigerator) .
I am storing shopping history of each family.
But for calculating the shopping cart i need to generate some statistics formula . But i have no clue how to do it. because there might be scenarios (for example birthday) , when the family will buy more products than needed, and it will make me false data for statistics. I want to ignore such scenarios.
Anyone has idea how and what statistics should i use?

pseudocode
assuming the customer had an account and your database is MySQL
every purchase must save customerid, product id/name ,date of purchase,comment(optional) to a table (e.g. purchased table)
customer has their own table that includes at least their personal info(e.g. customer table)
lets say customer browses the product (viewing the website)
• customer clicks the product
• system/server counts the number of purchase in purchase table
• if the number of purchase is more than one then
- get the last date of purchased product - the current date purchased product = frequency of product needed by date
- total number of product purchased / total number of times the product purchased = frequency of product needed by item count
UPDATE
I would suggest that the purchase table has a field that specifies if the current order/purchase is an occasional field instead, so it would be excluded.
example
• system/server counts the number of purchase in purchase table if the purchase is not occasional

Related

Stripe: Can I create a single "1 month free" promo code for multiple products?

I've been reading though the Stripe documentation but can't figure out if it's possible to have a single promotion code for multiple products, to give a 1-month discount, for products which have both monthly and yearly pricing.
Our product setup is like this:
Basic tier product
Monthly price (upsells to yearly price)
Yearly price
Plus tier product
Monthly price (upsells to yearly price)
Yearly price
I’d like to set up a single promotion code to give to customers, to discount the price of one month, regardless of the product they choose and whether they select monthly or yearly billing.
If I set up a 100% discount coupon then I can apply it to both products, but then if the user chooses annual billing, it discounts the price of the entire year (we only want to discount the price of one month).
If we set up fixed-amount discount coupons, then I'd need to create different promotion codes for each product (we only want to give customers a single code).
Maybe this simply isn't possible with Stripe, but it seems like quite a reasonable/common use case, so wanted check.
Any help much appreciated!
Unfortunately this is not possible with a single Stripe coupon. You would need to create at least two different coupons: one for the basic tier product worth one month, and one for the plus tier worth one month.

Choose correct PRODUCT COST from ROW based on amount sold

I am making a sheet to CALCULATE REAL REVENUE from each sale I make on my online store.
The problem is that the COST of my products is not always constant. It varies depending on many factors so each time I make a purchase I add the NEW PRODUCTS COST (LATEST COST).
Each time I make a new purchase I will add the QUANTITY and the new COST. (PURCHASE 1, PURCHASE 2, PURCHASE 3,etc).
Screenshoot of my sheet with example on ROW 41
In Column B I want to know which is the CURRENT COST based on the amount of TOTAL SALES of each product.
For example:
If I have sold less than 100 ( Pruchase 1 QUANTITY) then I need the formula to choose value of E41 (PURCHASE 1 COST).
If I have sold MORE than 100 and LESS than 300 (which is the SUM of PURCHASE 1 & PURCHASE 2) I need the formula to choose value of G41 (PURCHASE 2 COST) AND SO ON...
The formula I have come up with so far is this:
=INDEX(41:41,,IF(C41<=D41,COLUMN(E41),IF(C41<=D41+F41,COLUMN(E41)+2,IF(C41<=D41+F41+H41,COLUMN(E41)+4,COLUMN(E41)+6))))
This formula WORKS but only for the first 3 PURCHASES.
I need a formula that has no limit but I don't know how to make a VARIABLE formula.
Please take my words literally when I say that I wouldn't waste one minute on trying to solve your problem with your current sheet design. You would need VBA, and then extract quantities and prices from each purchase without the ability to filter on columns. (Minute is up.)
What you need is a Purchase database: ItemID, Date, Quantity, Price, maybe Ref#. From that you can pull out the transactions for any item by filtering on the item and the cost by using functions like SUMIF. However, this just brings the real problem within reach without solving it.
The problem is that when you buy 100 pcs #42 your price is 42. Then you buy another 100 pieces #46 your average price is 44. But if you sold 50 pieces with a cost of 42 then the average cost of the remaining 150 is 45. Therefore you can't determine the average cost of any remainder without knowing the quantity sold and the average cost applied to that sale. To solve that problem you will still need VBA but the suggested db format of purchase record would at least support such a solution.
Not so long ago I programmed a solution where there were additional columns in the db and each sale was recorded in 3 columns (much like your present purchase record): date, Qty, Ref. In this way I could trace the sale of each individual purchase (this was for shares trading). The sale of the newer quantity wouldn't start until the earlier quantity was sold out.
Perhaps you don't need to trace where the purchased quantity went to and just need one column to count down the balance to zero. That would be much simpler but has the drawback that you can't roll back errors. In the end the rollback was the reason why I abandoned the design. The key to the ability to abandon it is a similar db for sales: date, qty, price, Ref#.
With such a setup you might design a system to either extract the average or FiFo price from the purchase side and associate it with a sale. If the condition is that it should be done with worksheet functions you could add a column for "current cost" in the purchase db, changing with each purchase, which you look up by date from the sales side using VLOOKUP or SUMPRODUCT, having set a cost price applicable from the day of purchase until the next. If that appeals to you, a method must be found to deal with days on which there are both purchases and sales.

How To Figure Out Repeat Purchase Rate With Multiple Variables

I have data in an excel sheet that is essentially a list of all orders for my company over its life span (approximately 14 thousand orders if it matters.) The following fields are relevant for what I'm trying to do currently.
Purchase date (i.e. 6/23/19)
Customer ID (unique ID given to each customer, this ID is constant across all of a customers purchases)
Product category (widgets, woozits, etc.)
Sales person (John Doe, Jane Doe, etc.)
What I'm trying to figure out is our repeat purchase rate by category, and then by sales person.
So ideally I'd like to be able to determine something like
Product category: Widgets
20% of people whose first purchase from us is a widget, purchased something else later on
Of widgets sold by John Doe to first time customers, 15% of the customers purchased something else from us later on
Of widgets sold by Jane Doe to first time customers, 25% of customers purchased something else from us later on.
So basically trying to figure out if different sales reps have better repeat purchase rates on their orders, however we must divide this by product category as our repeat purchase rate by category is going to vary widely (and some sales reps only sell items from certain categories so it would be unfair to compare across categories.)
I believe to do this I need to figure out how to say something like
"Find every widget John Doe sold ; see how many have customer ID's that did not appear on an earlier date ; then see what % of those customer ID's appear at a later date regardless of the next product category or sales person they purchased from."
Hopefully someone can help. I apologize if I didn't explain something particularly well, if there's any confusion I can try my best to clarify.
Thank you!

Product discounted price in product page - Hybris Commerce 6.6

I have target discounted price for an SKU, with no product group or customer group filters, just a "target price" delimited by dates, that I want to show in the product page. This is maintained in the product management screen, and it's not promotions related.
As far as I can tell Hybris only calculates the discount when the product is placed in an order (the target price does show correctly in the cart page).
I tried creating a virtual cart in the product detail page, but unless I save the cart, Hybris doesn't allow me to calculate the discount. I don't want to save a cart each time a person goes into a product page.
What's the correct approach for this? Seems a pretty normal requirement.
Thank you
You can use Price Rows with validity period (start and end date). Import all prices with validity date to system. List product prices in PDP on custom section with custom code.
A voucher/discount is applied to a cart, not to a product. Even if a voucher is only applicable for a specific product, hybris will only calculate a discount for an order/cart.

How to avoid Shopping Pricing Rule when applying Catalog Cart Price Rule?

I have an ongoing 50% Off Catalog Pricing Rule currently active across my store. A few days back I have also distributed coupon codes on a Radio show with 25% Off. Now i have a situation where customers with these codes are applying the code and receiving a double discount. My $10 product is selling for $3.75 (50% + 25%).
I want a functionality where when the customer applies the coupon code, the code does apply but ONLY on the original price of $10. Thereby selling the product at $7.5. It should overlook the catalog rule. So the customer can choose to either go with the Catalog discount or Coupon discount but not both. Is this possible?

Resources