Customize WooCommerce data sent to Remarkety

Remarkety's plugin for WooCommerce includes the following Wordpress filters that you can register to your custom plugin and modify the data before it is send to Remarkety:

  1. remarkety_cart_data
  2. remarkety_order_data
  3. remarkety_customer_data

Sample 1 - change "accepts marketing" value for a customer

By default, there is no "accepts marking" field for customers in WooCommerce.

If you customize your store to include this field, you can use the remarkety_customer_data filter to change the data sent to Remarkety and include the correct values for this field.

Here is a sample plugin code that marks all customer as "accepts marketing - true".
Modify the sample code to include your custom logic for getting the correct "accepts_marketing" value (true/false).

<?php
/*
Plugin Name: Remarkety customer sample
*/
if (! function_exists('remarkety_customer_sample')) :

    function remarkety_customer_sample($data){
        $data['accepts_marketing'] = true;
        return $data;
    }
    add_filter('remarkety_customer_data', 'remarkety_customer_sample');

endif;

Sample 2 - add free products to cart

<?php
/*
Plugin Name: Remarkety test
*/
if (! function_exists('remarkety_cart_free_product')) :

    function remarkety_cart_free_product($data){
        $items = $data['cart_data']['cart'];
        //The product must exists on WooCommerce and the product_id must match th correct product.
        //All the following properties are mandatory on cart items.
        $freeProduct = [
            'product_id' => 123456,
            'variation_id' => 0, //optional, only if there is a variation_id for the free product
            'quantity' => 1,
            'line_tax' => 0,
            'line_total' => 0
        ];
        $items[] = $freeProduct;
        $data['cart_data']['cart'] = $items;
        return $data;
    }
    add_filter('remarkety_cart_data', 'remarkety_cart_free_product');

endif;

Sample 3 - customer reward points

<?php
/*
Plugin Name: Remarkety customer sample
*/
if (! function_exists('remarkety_customer_sample')) :

function remarkety_customer_sample($data){
$data['reward_points'] = get_reward_points_from_crm();
return $data;
}
add_filter('remarkety_customer_data', 'remarkety_customer_sample');

endif;
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.