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!
Related
My question is very specific and not for all, I want people to help me with my train of thought.
What I want to build : for example I have service where all people (not logined) can create they post with some data like news and publish it for money.
How I think it should be built (in 2 steps):
Man click on the link to page with form that create posts and router go to this page
He fills data and click submit
Server checked form and if all OK, session.set this data that he fills and route to the next step (pay money
to publish they post)
(I want to build this with stripe so) He clicked on stripe checkout button and pay some $$, if he paid then show message, all ok, we session.get data that he fills from previous step, and on server we insert his post and go it, if not show message that something wrong
Technical Plan session.set session.get, it is right ?
And if someone slip through form with fills and go to payment page, how to check it ? If session.get === undefind or something like this, reroute to previous step ?
As you can see I have a lot of questions, and I cant find answers in google or some documentation tutorials and etc. maybe some have answers to it
Your question is very wide. Consider narrowing it.
Your 2 first points make sense. It's ok. The third and forth are wrong.
Technical Plan session.set session.get, it is right ?
No it is not. You plan to use the information you hold in a Session variable to publish data validated on client side. It does not ensure the validity of your data. This is a bad idea because anyone can open the console and edit the data to make it different/invalid regarding your rules of validation. All it takes is a Session.set ("yourData", "YouHaveBeenHacked");
What you need is to call a Meteor method on server side to add an entry to a dedicated collection. You add another field (e.g; status) to keep track of the post payment and publication and return the data entry _id that you store in a Session variable.
This way, your method can return an error if the data does not fit into your requirements.
Side note: you also need to add a CRON job serverside to get rid of all the old post tentatives that have not been paid for (user left his browser, he closed tab, etc.).
I would look for some feedback on tracking user activity on an commerce website using th google analytics commerce capabilities.
I can't fully understand those 3 parts :
Adding an item (ecommerce:addItem) : obviously when some user add a thing to the cart
Adding a Transaction (ecommerce:addTransaction) : that's where I'm very confused
Sending the data (ecommerce:send) : that's obvious
Can those 3 event append at a different moment ? in what manner ?
What would be a real-world use case that would make you use execute ecommerce:addTransaction and ecommerce:send at a different moment ?
This thing makes me wonder a lot, and I'd like to have some experienced feedback on this as you tend to easily break your stats if something is not done week enough
Thanks in advance
EDIT
So the main purpose right here is to get stats for the pending orders (you add stuff to your cart), and the complete orders (you paid for the things you added).
Right now I only send it all when the order is complete, and things are working pretty good in analytics, but I just don't know anything about the ones that did not complete.
This question was a lack of knowledge.
Simple ecommerce plugin has nothing to do with the enhanced ecommerce plugin
You won't track that much with the first one, except the checkouts. A plain, one order at a time, revenue value.
If you want a deep insight on your users behaviors (when i say deep, I mean it), You have to go for the second one.
We might be able to debate over the unusefullness of the first one; and the fact that its existence in itself compared to the second is completely misleading, as when you first get in, as usual with google, you get flooded by an endless documentation
ecommerce:addItem does not add items to a cart; it adds items to a transaction (with "conventional" ecommcerce tracking there is no cart tracking, you'd have to use enhanced ecommerce tracking. Actually your title refers to enhanced ("ec:") and your question to conventional ecommerce ("ecommerce:") tracking).
So ecommerce:addTransaction starts a transaction; here goes the stuff that affects the transaction as a whole, like transaction id, tax on the total purchase or shipping costs.
Now that you have started the transaction you can add items to it that are associated via the transaction id.
Finally the ecommerce:send command tells Universal Analytics that the transaction should be processed on the server. "send" is actuall a misnomer; addItem and addTransaction do already send data to the server (they each create an request to the tracking server and thus count towards your hit quota).
The reason for this is, as far as I can tell, that the information is transmitted via url parameters (you call the Google Analytics endpoint which returns an transparent pixel). The maximum length for an url request is limited (actual limits depend on browser and browser version).
So the transaction is broken up into multiple parts not because you want to execute the commands at different moments but so it can be transmitted via Url parameters without being truncated. The send command merely tells that you are now finished adding new parts to the transaction and the data can now be processed.
I'm meeting an issue to implement gift card in an e-commerce website working with paypal.
I'll try to be as clear as possible.
Once the user has validate his cart, he can enter a code as gift card to get a discount. The gift card (and the code) can be used only once and it isnt linked to the user.
So when the user enter the code, I check if it exist if it allready has been used, get the discount and so on...
On the postsale of paypal (once the paiment has been accepted), I set the gift card as used.
Now, how can I prevent the gift card beeing used twice (or more). Because when user enter the code and goes to paypal, another user can use this same gift card while the first user did'nt confirm the paiment (and didnt process the postsale).
I thought giving a status to the gift card, for instance 'In use' before redirecting to paypal but if the user leave paypal without confirming his purchase, the gift card will always be InUse and then I wouldnt be able to check it again....
I hope I've been understood and thanx for your help :)
Well, you could check if the code has been used when they enter it, then check again at the point of the transaction being completed. The second check would have to be implemented carefully, with a single locking database transaction that checks if the code has been used, then marks it as being used.
If the code had been used by someone else before the transaction is completed, the transaction would have to fail with an error. However, presumably this would be quite a rare case.
Beyond this, I wonder if you should rethink your design. A single-use code that is not linked to a user seems unusual--normally this would be linked to a specific user, which would make it easier to handle. What is your use case?
I'm trying to get Google Analytics eCommerce tracking to play nicely with our site's payment gateway, Worldpay. A solution, which I'd prefer NOT to use has been posted (link below), but involves extra clicks for the shopper, which I was hoping to avoid.
http://www.tatvic.com/blog/google-analytics-worldpay-ecommerce-tracking
The shopper is taken to Worldpay's website to process cards, where no javascript is available and the GA eCommerce tracking breaks down.
Let me walk you through the steps:
A shopper arrives at our site where Google Analytics is set up to successfully track their movements.
The shopper clicks "ORDER" and is taken to Worldpay's website for credit card processing. The shopper completes their order on Worldpay's site and their shopping experience is over.
Worldpay POST us their 'payment response message' which is sent to our designated page 'response.cfm'. This message contains various details about the order (cartID, ammount, etc..) which we file in the database as a completed order.
My question is, and please excuse my ignorance, but is it possible to use this automated payment message, sent to our response.cfm page to send all the GA data to google ? I don't want to involve the user/redirect them back to us, if I can help it.
Worldpay allow us to send our own variables to them, then return the variables in the payment response. I was hoping we could use this feature to make it work? It would be a similar solution to the link above, but wouldn't need the shopper to click the button at the very end (and get a warning message)
I know this is an old question now but as no-one has posted thought it would be worth posting my solution to this problem.
Build a response script which is purely there to handle the response, not display the message, for example response.php. Also create a page which displays a message, for example complete.php
Inside response.php include:
<?php if($_REQUEST["transStatus"] == "Y" && $_REQUEST["testMode"] != "0" && $_REQUEST["callbackPW"] == "your_password"){
//update order status internally here
?>
<meta http-equiv="refresh" content="4; url=complete.php?parameters">
<?php } ?>
Replace "parameters" with any information from the booking you'd like to pass to Analytics. Inside complete.php include your Analytics code referencing to $_GET parameters as required.
For extra security i'd recommend passing an additional parameter with a secret hash (different for every transaction) and compare that in the above if statement as well.
I hope this is a useful solution :)
Sorry if the title's a bit vaque, I promise I'll clear it up bellow:
First of all, a while ago I asked a question about selling serial keys :
How can I execute a custom script after purchase with Ubercart for Drupal
The information I posted there may help clear things up in this question but I doubt it much because this question is a bit more general.
Basically, I don't want to execute my custom code until I know the payment has been cleared and the moneys in my account. I was a bit unsure what the conditional action thats trigger is 'Customer completes check out' did though? When it says they completed checkout does it necessarily mean successfully and the money is in my account or not?
If not, how do I make Ubercart wait until it knows I've got the money from any PSP (e.g. Google Checkout, PayPal, etc) to execute my custom code? I can't work it out, is it even possible?
It's not documented or exposed as something that should be reliable but I think that using the 'Customer completes check out' trigger is the way to go.
Bear in mind that the following applies to Ubercart 6.x-2.4. (Latest version as of today)
From what I looked at the code, it seems that the trigger is only executed on successful orders. Whether a successful order means that you have received payment, that depends a lot on your current configuration and the different payment gateways or method you are using, but in general situations and configuration.
That trigger is only launched from one function:
function uc_cart_complete_sale($order, $login = FALSE);
If you do a module-wide search on when that function is executed, it should give you a rough idea on the different situations. Basically I found out that it's being executed from a few payment modules (paypal and 2checkout for example) as well as when you reach the cart/checkout/complete drupal page, which is generally on successful orders. The paypal module, which you specifically asked, seems to be calling that function when a 'Completed' IPN status is received.
It shouldn't be hard to try out a few purchases (right and wrong) and see if your trigger executes only when the order is properly charged.