Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Sending third party information to checkout in WooCoomerce WordPress


We are building our own product customization tool and would like to send the result information to Woocommerce checkout page!

Out of our tool we get a product (with sizes, color and all) + a price. We need to send those to Woocommerce so that it takes care of the sales and customer registration.

(I'd like to avoid having to learn all about woocommerce to do this).

So if you know how we should format our information + where and how to send it would be great help (API, ...?)

Many thanks,

Answers (3)


Doug Montgomery answers:

Just a comment, wish I could help:

As a 'backyard' Woocommerce guy (as in backyard mechanic) that doesn't sound too easy. It would require creating a new product automatically, ie importing all the specs and info and then a redirect to the checkout page after the product was created.

Woo has an import/export tool add on for a cool $199 and I'm guessing you would have to incorporate that also, or code one yourself which wouldn't be too fun when it came update time.

I'm curious now if this can actually be accomplished in a 'fairly' simple manner. I'll be watching for more info on this. I like to learn :)
Good luck

Jonathan Surinx comments:

Many thanks for your comment!

I was hoping for an easy solution... Maybe with their API or something. I'll have a look...


Gabriel Reguly answers:

Hi Jonathan Surinx,

I am afraid that you need to add the product to cart before going to checkout.

Then you can redirect it to checkout.

Does the product exists at all in WooCommerce or is it all custom?


Jonathan Surinx comments:

It's all custom (was even thinking to host this on another server and put it in a frame on the website... Already developed something similar for Facebook plugin throught third party sites so I thought it would also work).

If adding to the cart can be done it's still a hint, any trial with that?

Gabriel Reguly comments:

Hi Jonathan Surinx,

I have done a work for a client where we have a dummy product that was filled with the info and then added to the cart.
That was no small feat, but it is doable.

Moving from cart to checkout automaticaly is easily done. ;-)

Do you have a budget for that? Or just looking for advice?



John Cotton answers:

I take it that your product customisation is a relatively complex UI which is why you think it needs to be separate.

However, there's nothing to stop you putting whatever HTML/JS you like in a single product page.

What I've done successfully on many occasions is create a standard, simple product and then used the woo hooks to drop my extra logic in.

function woo_extended_add_to_cart() {
global $product;

if( $product->sku == 'my-product-sku' ) {
include_once( 'template-extendded-purchase-logic.php' );
add_action( 'woocommerce_before_add_to_cart_button', 'woo_extended_add_to_cart' );

In the code above, I check that the current product is the one I want to play with, and then add all the HTML and JS I like from my include. You could use a custom single.php template if the standard woo product template doesn't give you the layout you need for your customisations.

On post back, you could hook into woocommerce_add_cart_item_data to grab all your settings data (you could ajax them back if you wanted, but the principle is the same) and store the values in the cart meta data. If the page gets reloaded, you can retrieve your values from the same meta data.

When the cart goes through to checkout, you can use the woocommerce_add_order_item_meta hook to add the values to the order meta.

There are other hooks such as woocommerce_order_item_meta, woocommerce_get_cart_item_from_session, woocommerce_cart_item_data_max and woocommerce_checkout_update_order_meta which might be useful depending on the exact nature of what your customers can order. Of course, you will need to use the price hooks to vary the cost based on customisations, but that's pretty standard (there are several plugins available that do that for generic customisations like size or color - it might be worth buying one of those to see how it's done).

In short, all of your customisation values are stored in meta data and you can make your customisation as complex as you like.

It isn't a 10 minute job, but a competent PHP developer should be able to integrate your existing HTML and JS in a couple of hours or less.

I can't really give you any code as it's all very implementation-specific, but if you look at the hooks I mention above you should be able to see what I mean.

Jonathan Surinx comments:

Hi John,
Thanks a lot for your reply... I guess this will take me too much time as it's coded with an entirely different language (I can output the labguage I wish thought).
But for now I'll do 2 separated entity (payment from woocommerce itself for some products) & payment from my custom too too, will be faster.
Many thanks to all for your help!