Woocommerce: Table specific product sales with metadata in front end - php

Ok so here is my aim:
I have a single product with no category. I have used the 'YITH Woocommerce Product Add-ons' to add a group of checkboxes to the product that accepts 4 selections. The order is raised and the product has the 4 selections of checkboxes listed in the cart/checkout pages and also on the order page in my account. So far so good! Now...
I wish to produce a table on the frontend that lists all the sales of the product with the order date, first and last name of the customer and the 4 selections the customer made when ordering the product. For example...
Product X Sales:
First Name | Last Name | Date | Select 1 | Select 2 | Select 3 | Select 4
I have looked at the plugin 'Product Customer List for WooCommerce', this has a shortcode for displaying a list of customers and date when the product was purchased however; I don't have a way of extracting the metadata stored by the YITH Product Add-on field attached to the product sale.
Any help would be appreciated either with or without the Product Customer List plugin. Looking for some code possibly to recall the data per product sale and list it correctly in a frontend table.
Thanks in advance!

This option is now available in the pro version of the plugin

Related

Adding to the quantity field from product add on in woocommerce

Can anyone help with my dilemma please? I have a product that i want customers to be able to select the delivery for. For example, i have product x, the customer wants 5 products delivered across 3 months.. lets say in jan i want 1, feb - 2 and march - 2.. so quantity of 5 in total .. i want to get the quantity displayed as 5 and then price displayed for qty*price of product as well.. this has to be displayed in the cart page as well .. I have created product add ons using the woocommerce plugin, now i want the product add on fields to include these as a quantity .. i am fairly new to php .. can someone please help me with this?

How to add automatically products (just in the backhand) to orders in woocommerce?

I think is necessary some custom PHP, how can be added automatically to the backhand of the order 3 products (brochure, box and leaflet) for each order?
I do not want this to be visible in the front end like using plugins like chained products but I would like simply that for each order in the backhand automatically would be added 3 specific product to this order.
The three product would be products with their own SKU code and ID of course.
if you have the product id you can use
WC()->cart->add_to_cart($product_id,$quantity);
to set any product you want to customer's cart.

Woocommerce Order Export

I'm using
WooCommerce Simply Order Export (Plugin)
in Woocommerce Website. Using this Plugin when I export orders which are under specific Order Statuses(e.g. Processing, Completed etc), Plugin give me an option to select date range and no. of columns(e.g. Product Name, Product Quantity, Variation etc.), But the Problem is:
If Order-1 contains 1 product with some quantity(e.g. Fanta (Quantity = 4)), Similarly Order-2 contains the same product(e.g. Fanta (Quantity = 2))
So I need to update the Plugin in which I create a button to export Accumulated Quantity of Products(Sum of same item across all Orders), I need 2 Columns in Exported CSV(Product Name, Accumulated Quantity), Kindly help me in this updation.
TIA
A plugin that you can use (with the functionality you need) is this one:
Product Sales Report for WooCommerce
If you want to get a custom report, you can use the WC_Admin_Report() class and the get_order_report_data() to build your custom query.

Modeling Product Inventory Variants E-Commerice with Images PHP

There are many different answers to satisfy different online store needs.
A lot of the example I see don’t take into consideration **inventory and images ** and treat styles and sizes as attribute like tags and try to be flexible. This seems wrong to me. My Product that hasMany styles/color that hasMany Sizes.
Here is how i want to layout it out
Product
id | name | price
1 | shirt | 10.00
^ Styles < Images
id product_id name id styles_id filename
1 1 red 1 1 image.jpg
2 1 blue
^ Size
id sku styles_id name inventory
1 n1 1 m 50
2 n2 1 l 50
I don’t see many examples of this but this is what makes sense most to me. Am i totally wrong and bad to do it this way? With styles having its own table I can use a FK with images to load different looks of each style
I know one flaw is that what if I have a product that has only one style and one size. Like a winter coat. Then I to use extra tables. Visually with PHP I will just make it all one form. Will I run into an issue when i start working on cart and orders?
Note: I am using CakePHP
Response to the parent child method
Yes I have seen that before, Wouldn't you have repeated fields or empty fields, for example your table would look like this
id role color size inventory price name
1 parent - - - - artShirt
2 child red m 20 50.00 -
3 child red l 20 50.00 -
4 child blue s 20 50.00 -
5 child blue m 20 50.00 -
how would you link img to products that are red?
id product_id image
1 2 redImg.jpg
1 3 redImg.jpg
the concept i really like is called Parent Product - Child Products.
The Parent Product is given a sku for reference, but its not a buyable product. It represents the product, like the ArtSir Shirt. It contains a product description for ArtSir Shirt, qualities, keywords, etc.
the Child Products are the actual buyable products. the shirts. there is one record per child product with the sku, color, size, price, weight, inventory, etc. they are related to the Parent product by the parent product sku. for most merchants inventory is critical so having a db record per sku is really the only practical way to do this. (not to mention if you need distinct UPC or EAN codes)
the parent products and the child products can all be in - one simple happy db table. like a family :-) You call the parent product with its sku, then get the child products with the parent product sku.
and then when you get the child products, you have the option to filter out the ones with no inventory and not show them.
Showing product pictures on a product page for specific colors -- so this has nothing to do with the products being buyable or not. this is the presentation. the simplest (hack) is to put that information in the Parent product record. fields for Color 1, photo link, Color 2, photo link, etc
Otherwise you could have a separate db table to do this. Just try and confine its tasks to the presentation.
Always pass a product id to the cart - then the cart looks up the product price in the product table. If you pass the product price openly, then it can be easily hacked. When you look up the price you can also confirm inventory.
Suggest that there be one step before billing - where you check price and inventory again to confirm everything is correct before charging the customer.
==============
edit in response to question. you asked:
"Wouldn't you have repeated fields or empty fields, for example your table would look like this"
yes you will have empty fields. in 1985 or 1995 that was important. its not important any longer unless you are running your web site on a machine from that era.
bottom line you have to be able look up a sku and get the price and inventory. you could put arrays or data structures into a field.
but then you are having to pack and unpack them every single time you make a db call.
how would you link img to products that are red?
you can hack it by creating fields for the parent product to hold the image links, a color reference, a name, etc. color01, photolink01,color02, photolink02, etc. its a hack but it will work.
remember you are pulling all the page display information from the parent product. so this is just more display data.
you also have the option of having a photo field in the child product record. which you might need for product feeds. so then you could take the color - photo results from the child products, and use that to create the display.
otherwise make a db table for the display. and that table could also help with uploading the product photos and assigning them to the correct product.

Change product prices based on category in Magento?

What I'm trying to do is change the price of a product, based on which category the customer is shopping in when they add it to the cart. The reasoning for this is that we are selling tours, and the prices change based on what island you are coming from since the tour includes airfare. The categories are set up like this:
| Oahu | -> |Inter-island|
| Maui | -> |Inter-island|
| Big Island | -> |Inter-island|
| Kauai |-> |Inter-Island|
Is there some way to change the price that is being pulled into the cart when the item is added? I have already added custom attributes for each product that contains the price for each island, and it displays correctly in the categories, however the cart is showing only the default price when the tour is added.
I'm not necessarily looking for any code just some ideas on how to accomplish this
You simply need to add 4 separate tours. Duplicate your Oahu tour for example and then and simply change the price.
Do you have limited set of seats or something for the tour itself?

Categories