
Redirecting WooCommerce Cart to an External Website
- September 22, 2016
- Leave a comment
WooCommerce being the number one choice for developers as well as store owner allows selling products and services online. While it is a complete e-commerce solution, it can also be used for product display only by using catalog settings. However if you want to redirect your local cart to external site, there is no such integration option available by default.
It will require the modification of checkout process. You can use the following code to hook the WooCommerce checkout process by redirecting it to the external product markets:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
add_action('wp', 'checkoutRedirectToExternalSource'); public function checkoutRedirectToExternalSource() { global $post; global $woocommerce; if (isset($post->ID) && $post->ID == woocommerce_get_page_id('checkout')) { if(isset($woocommerce->cart->cart_contents) && count($woocommerce->cart->cart_contents) > 0) { foreach ($woocommerce->cart->cart_contents as $item) { // code here to process the $item as product data. } } } } |
User Comments