Best Way to Pass variable to Woocommerce Product? - wordpress

Here is the setup.
Customer fills out form of information for product specifications. This creates an entry in the db with a unique detailsID.
They then are taken to a product page, with many variables. They select the variable product and checkout.
Now in the db they have an order as well as a separate table with the details of their request.
What is the best way to connect the product they bought with the detailsID?
I would like to basically pass the detailsID to the product page, then add this detailsID to the product. Or add the orderID back into the details table.
I keep going around whether to add this as meta data, or use a session, or just do post order logic to add the order ID back into the details table.
I really just need to link the two once the order completes but am not sure the best method to do this. I am pretty new to Woocommerce so don't know a lot of the hooks yet.
Thank you so much for your suggestions!

After a lot of research and experimenting here is the method I have decided on. This seems to add the information in a variety of places to make it easy to track orders and to insure that the customer is getting the customized product they want.
add custom data to woocommerce
I am using this method very close to how it is spelled out in this great article. This was really helpful for me being a woocommerce newb.

Related

Multi Store with Subdomains

I want to create multiple online shops for selling merchandise products for companies. The products are basically identical but should be personalized in dependence of the company I am building the shop for. Because I do not want to build a new shop every time a new company joins the program I am looking for something like that:
www.myshop.com : One shop with the underlying product database and checkout system - not showing any products, just as a parent structure
www.company1.myshop.com : A slightly personalized shop where only a selection of the product catalogue is available
www.company2.myshop.com : A slightly personalized shop where a different selection of the product catalogue is available
Do you get it?
Does anybody know a tool for that?
Thanks in advance!
I already looked into WooCommerce, Shopify and even WiX. As far as I understood what I am looking for is not supported.
Since your example is based off of subdomains, you can choose to assign a Shopify store to each subdomain. Each store feeds from your inventory and accounting, giving your customers the illusion of a custom experience. Or you can just simplify your life, have one store, and assign your customers to view collections specific to them. That is the smart move. You may not like that, but it would work a peach for you. You just tag customers to see their specific collections, of products specific to those collections. Simple.
I can also think of a dozen other ways to pull this off with Shopify, but that is me, not you. For an opinion question like this, SO is not the right place to ask these kinds of questions, but I answered anyway. Your mileage may vary of course.

WooCommerce Zip Code Pricing per Customer

Sorry I don't have any code to show yet as I'm just trying to find a solution.
I'm in need of a way to set the price of products based on the users billing zip code. I have a custom registration form, I was thinking of somehow figuring this out during that process. Basically after they fill out their billing info, somehow check their zip code and and apply a price for that customer.
I may be able to write a custom API that would take the zip code and return a price. But what would I do with this price? Store it in user_meta? Then I would have to override $price in a million different templates.
I have googled this and didn't come back with much.
What would the best approach be for this?

Need some hints for my own WP Theme

After taking some online tutorials I am willing to create my own custom theme for my myself. This is going to be an online Contact Lense store! So far I have learned how to generate and use Custom Post Types, Custom Taxonamyies, Metaboxes , and Option pages.but there is still one confusing part left for me(hopefully not more! :-))
I need to get some user inputs through HTML Select Options like following image to finalize the users orders:
Now my question is:
1- Do I have to create some thing lik Metaboxes to manipulate these data from users?
2- can I handle these kind of data through simple Form ans Post function in PHP? If so where should I store these data? Do I have to create a table on my own to handle these things?
I really appreciate your time regrading this post,
What you're asking for carries a little more complexity than you think!
Let's break this down into its meaningful steps:
A user visits your shop, and decides that they like what they see and wants to make an order
The user fills out a form defining their exact eye requirements, quantity, as well as their contact information
Upon completing this form, a new order has been created
But wait.... how will you get paid? What happens if the user's computer explodes before the payment goes through? How will you know to send them their contacts without first knowing the payment even succeeded?
This is where things start to get tricky. You need to be able to keep a record of orders for the sake of your users, but you also need to look out for your own interests too. Your business is doomed to fail if you're sending out expensive products to people without the proper assurance that you're getting paid.
This is where you'll need to set up a Merchant Account with a service like PayPal or Google Checkout. As much as I despise PayPal, their Instant Payment Notification (IPN) System has been very reliable for me. What this does is automatically send a POST request to your server with all of the information you need to finalize the checkout process and alert your user that their payment has either succeeded or failed.
So with this in mind, how does this affect our step-by-step process?
A user visits your shop, and decides that they like what they see and wants to make an order
The user fills out a form defining their exact eye requirements, quantity, as well as their contact information
Upon completing this form, a new order has been created with a status of pending
The user is then sent to PayPal/Google Checkout to enter their Credit Card information to complete their purchase
PayPal/Google processes the payment
PayPal/Google sends your server the results of the processed payment
The corresponding order is updated with a status of Payment Received or Payment Failed for your own records
You send out the product to a very satisfied customer
So what will this mean from a Wordpress standpoint?
My first suggestion:
Check if a Plugin already exists that can handle this for you!!!
Seriously, this will make your life much easier. Handling people's money as well as your own stock is a nightmare all in itself, you don't want to be responsible for handling the code that drives it, or the possibility of security holes that you might not know about (that other plugins may have already addressed). WooCommerce is a popular one. See if that can handle what you need.
If a Plugin can't do it for you, then you'll need to:
Register a Custom Post Type for Orders
Create a new Order Post using wp_insert_post when a user submits the form with their POST data
Save the relevant POST data you need as metadata using update_post_meta
Send PayPal/Google/Whatever some Custom Information it needs to hang on to - in this case, the newly created Order Post ID - so that it can send it back to your own server
Set up a side-script to process the data sent by PayPal/Google Checkout/Whatever and send an email to the user detailing the status of their purchase and update the corresponding Order Post ID that was sent back by PayPal/Google Checkout/Whatever
(Optional) Set up a CRON Job to periodically scan all Pending orders in case a user's session was interrupted, or they bailed at the last second during checkout and send them an email notifying them about this and provide them a link to your website to reopen, reevaluate, and resend the order, or cancel and clear it from your database
Quite honestly, this would take even a seasoned Developer at least a few weeks worth of work just to get it in working condition. Presentation is a whole different animal.
Hopefully this will give you a step in the right direction. I doubt anybody here will give you the code to do what you need, because there's just too much to post. Entire libraries are built just for these kinds of things.
Good luck!

Wordpress : data exchange betweeen two plugins

I want to develop a website where teachers create exams and students pay money in order to pass these exams, so it's an e-commerce website where products are quiz.
The exams will be managed with a quiz plugin : i'll use Watu.
I still have no idea what e-commerce plugin I'll use.
What I want is to make exams as products so students can add them to cart, but I dont't see how can I do it : the e-commerce plugin manages its own products !!! Is there an easy way to do it ?
This is my idea: alter the quiz module so when an exam is created the script insert a row in the e-commerce table(s), so when I go to the e-commerce plugin I'll find a new product! But I think this is not a clean way !!
You might consider setting up woo-commerce setting a link as a software product that will be delivered on checkout.
You could build a quiz answer table in sql, deliver a generic quiz (via a link sold in the store)
the quiz table could have a field for quiz_id and you could have their answers recorded as a text field.
so the link would be delivered digitally thru the store, your answers 1-100 a-d might look like this:
userid: xxxxx
autodate
test: 1
Answer:abadddaeababadddaeababadddaeababadddaeababadddaeababadddaeab
so one entry would contain all the answers on the test in question in one field.
once committed you could return a result based on a difference function from a pattern mask.
how many wrong answers in the simple query.
You then can store the answers and draw data based on what particular answers they got wrong.
they can also retake the same test at a later date and you can see each time how they did.
advantages of using a single text field means that you can use a single compare to pull the data and it's short to store.
with a membership plugin. Give roles afther payments. Diferent roles for diferent levels of exam. It´s easy than make conexion with database.

Is an custom field accesible via URL/Search query etc.?

I'm going to set up a web shop that sells domain names.
Every domain is a single post, and every post contains about 10 custom fields.
My question is, are these custom fields accessible if I don't query them?
For example, you go to a single post (a domain overview in my case) and can you retrieve the values of my custom fields? Otherwise people can retrieve the code, without paying for it. Are those custom fields accessible if I don't query them, or not all of them?
Is it safe to keep the code's where you pay for in a custom field?
Thanks in advance!
You shouldn't be able to, but there's always the possibility of security holes in WP, or even something as simple as a brute force attack on the WP Admin area or your MySQL database.
I would err on the side of caution and keep any critical data in a separate system. Maybe after someone makes a purchase, you could have them log into a separate system to retrieve their activation codes.
Gumroad might be a decent end-to-end fulfillment system for you. Each of your domains would be a separate Gumroad product, and you could paste the shortlink into WordPress as a custom field. More info: https://gumroad.com/

Resources