Woocommerce Integration

¿How to integrate the platform with Woocommerce?

After starting your integration process in the platform, if your website is built with Woocommerce, these are the steps you need to follow to complete the process.

1. Go to Appereance>Theme Editor>Theme Files>Header.php and paste this code in Header.php of your page (Before "</Head>"). This is the general script of Filiatly.

<!--// Filiatly script //-->
<script type="text/javascript" src="https://[FILIATLY CLIENT URL]/integration/general_integration"></script>
<?php if ( is_front_page() ) { ?>
<script type="text/javascript">
AffTracker.setWebsiteUrl( "[ENTER YOUR DOMAIN]" );
AffTracker.generalClick( "" );
</script>
<?php }
?> 

Note: [FILIATLY CLIENT URL] is not the domain of your website, it's your Filiatly space. You can see it when you log in to Filiatly.
Example: https://cliente.filiatly.com
Also, in [ENTER YOUR DOMAIN] you have to put the URL of your website.

 

2. Go to Appereance>Theme Editor>Theme Files>Functions.php and paste this code in your Function.php page of your theme. This code allow to track your sales:

/**
* This code execute inside head tag filiatly in function.php theme
*/

add_action( "woocommerce_thankyou", "filiatly_thank_you_header_script", 20 );

if ( ! function_exists( 'filiatly_thank_you_header_script' ) ) {
function filiatly_thank_you_header_script($order_id) {
if ( $order_id > 0 ) {
$order    = wc_get_order( $order_id );
if ( $order instanceof WC_Order ) {

$order_id               = $order->get_id(); // order id
//$order_key              = $order->get_order_key(); // order key
$order_total            = $order->get_total(); // order total
$order_tax              = $order->get_total_tax(); // order total
$order_currency         = $order->get_currency(); // order currency
//$order_payment_method   = $order->get_payment_method(); // order payment method
//$order_shipping_country = $order->get_shipping_country(); // order shipping country
//$order_billing_country  = $order->get_billing_country(); // order billing country
//$order_status           = $order->get_status(); // order status

$product_ids = [];
foreach ($order->get_items() as $product) {
$product_ids[] = $product->get_product_id();
}

/**
* full list methods and property that can be accessed from $order object
* https://docs.woocommerce.com/wc-apidocs/class-WC_Order.html
*/
?>

              <script type="text/javascript">
                    // write custom action here
AffTracker.setWebsiteUrl( "[SUSTITUIR POR DOMINIO]" );
AffTracker.add_order({

    order_id : "<?php echo $order_id; ?>",
    order_currency : "<?php echo $order_currency; ?>",
    order_total : "<?php echo ($order_total - $order_tax); ?>",
    product_ids : "<?php echo implode (",", $product_ids); ?>"
})

                </script>
<?php
}
}
}
}

Note: In [ENTER YOUR DOMAIN] you have to put the URL of your website.

 

Congratulations, you're done!

You're ready to start managing your Partners and grow your brand through Filiatly!

🚀

 

If you have any doubts or you need any help, please contact us at clientes@filiatly.com