Integrating with SharpSpring's shopping cart allows you to automatically record web transactions from your online store and attribute those sales to SharpSpring leads and campaigns. This enables you to measure your end-to-end marketing ROI for eCommerce based businesses directly in SharpSpring. This article will detail how to integrate your shopping cart with WooCommerce.
|
Available with: | ||||
Marketing Automation | ✓ | ||||
CRM Ultimate | |||||
CRM PRO | |||||
CRM Free | |||||
Toolbar: | |||||
![]() |
|||||
Users: | |||||
Administrators | ✓ | ||||
Company Managers | |||||
Marketing Managers | |||||
Sales Managers | |||||
Salespersons | |||||
Jr. Salespersons | |||||
Integrating Shopping Carts
In order to integrate SharpSpring with WooCommerce, you need to have administrator access to your Wordpress account, as well as administrator access to SharpSpring. To set up and integrate a shopping cart, do the following:
Once purchased, that transaction should now show up in SharpSpring's shopping cart. |
|
Important: Shopping cart abandonment features are not currently supported by WooCommerce.
|
Note: If the lead's email, first name, and last name are passed in the
setTransaction call, it will also establish tracking on the lead (and create the lead if they do not exist in SharpSpring). |
||
Important: Pay close attention to the code that you add to functions.php. If you add incorrect code, you may be locked out of your Wordpress account.
|
||
Code Snippet for Functions.PHP File
The following is the supplied code snippet for use with Step 7 of the above procedure:
/* SharpSpring WooCommerce integration * This code will push completed orders and new leads to SharpSpring, but this integration does not support abandoned carts */ function my_custom_tracking( $order_id ) { //Get the order from WooCommerce $order = wc_get_order( $order_id ); $billing = $order->get_address('billing'); ?> <script type='text/javascript'> // SharpSpring setTransaction for WooCommerce _ss.push(['_setTransaction', { 'transactionID': '<?php echo $order->get_order_number(); ?>', 'storeName': 'Store Name', 'total': '<?php echo $order->get_total(); ?>', 'tax': '<?php echo $order->get_total_tax(); ?>', 'shipping': '<?php echo $order->get_total_shipping(); ?>', 'city': '<?php echo $billing['city']; ?>', 'state': '<?php echo $billing['state']; ?>', 'zipcode': '<?php echo $billing['postcode']; ?>', 'country': '<?php echo $billing['country']; ?>', 'firstName' : '<?php echo $billing['first_name']; ?>', // optional parameter 'lastName' : '<?php echo $billing['last_name']; ?>', // optional parameter 'emailAddress' :'<?php echo $billing['email']; ?>' // optional parameter }]); <?php //Get and loop through the items in the order $order_item = $order->get_items(); foreach( $order_item as $product ) { $product_sku_array = new WC_Product($product['product_id']); $product_sku = $product_sku_array->get_sku(); ?> //SharpSpring addTransactionItem for WooCommerce _ss.push(['_addTransactionItem', { 'transactionID':'<?php echo $order->get_order_number(); ?>', 'itemCode': '<?php echo $product_sku; ?>', 'productName': '<?php echo $product['name']; ?>', 'category': 'General', 'price': '<?php echo $product['line_total']; ?>', 'quantity': '<?php echo $product['qty']; ?>' }]); <?php } ?> //SharpSpring completeTransaction after all items have been added to the transaction _ss.push(['_completeTransaction', { 'transactionID': '<?php echo $order->get_order_number(); ?>' }]); </script> <?php } add_action( 'woocommerce_thankyou', 'my_custom_tracking' ); /* End SharpSpring WooCommerce integration */