Created
February 6, 2014 19:58
-
-
Save sparkweb/8851478 to your computer and use it in GitHub Desktop.
FoxyShop Plugin - MailChimp Ecommerce 360
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: FoxyShop - MailChimp Ecommerce 360 | |
Plugin URI: http://www.foxy-shop.com/ | |
Description: Extends FoxyShop to add MailChimp Ecommerce 360 tracking to your checkout fields | |
Version: 1.0 | |
Author: SparkWeb Interactive, Inc. | |
Author URI: http://www.foxy-shop.com/ | |
License: GNU GPL v2 | |
*/ | |
//Add to the product array | |
add_filter('foxyshop_setup_product_info', 'fsmce_setup_product_info', 10, 2); | |
function fsmce_setup_product_info($product_array, $product_id) { | |
global $foxyshop_skip_url_link; | |
$foxyshop_skip_url_link = 1; | |
if (isset($_COOKIE['mc_eid'])) $product_array['h:mc_eid'] = $_COOKIE['mc_eid']; | |
if (isset($_GET['mc_eid'])) $product_array['h:mc_eid'] = $_GET['mc_eid']; | |
if (isset($_COOKIE['mc_cid'])) $product_array['h:mc_cid'] = $_COOKIE['mc_cid']; | |
if (isset($_GET['mc_cid'])) $product_array['h:mc_cid'] = $_GET['mc_cid']; | |
//if (isset($_COOKIE['coupon'])) $product_array['coupon'] = $_COOKIE['coupon']; | |
//if (isset($_GET['coupon'])) $product_array['coupon'] = $_GET['coupon']; | |
//Always return the new, complete array | |
return $product_array; | |
} | |
//Add to the checkout fields | |
add_filter('foxyshop_non_verification_fields', 'fsmce_foxyshop_non_verification_fields', 10, 2); | |
function fsmce_foxyshop_non_verification_fields($arr) { | |
global $product; | |
if (isset($product['h:mc_eid'])) $arr[] = 'h:mc_eid'; | |
if (isset($product['h:mc_cid'])) $arr[] = 'h:mc_cid'; | |
return $arr; | |
} | |
//Set MailChimp Cookies | |
add_action('init', 'fsmce_set_mc_cookies'); | |
function fsmce_set_mc_cookies() { | |
$number_of_days = 30; | |
if (isset($_GET['mc_eid'])) setcookie("mc_eid", $_GET['mc_eid'], time() + (86400 * $number_of_days), "/"); | |
if (isset($_GET['mc_cid'])) setcookie("mc_cid", $_GET['mc_cid'], time() + (86400 * $number_of_days), "/"); | |
//if (isset($_GET['coupon'])) setcookie("coupon", $_GET['coupon'], time() + (86400 * $number_of_days), "/"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment