Skip to content

Instantly share code, notes, and snippets.

@mattowc
Created February 8, 2013 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattowc/4741202 to your computer and use it in GitHub Desktop.
Save mattowc/4741202 to your computer and use it in GitHub Desktop.
This represents a basic idea or concept behind how we could add those attending single's mixers to mail chimp.
<?php
/**
* This is a simple snippet showing a hypothetical
* solution for adding users to a mailing list in
* mailchimp.
*
* @author Jonathon McDonald <jmcdonald.ut@gmail.com>
*/
add_action('init', 'jm_add_actions')
/**
* This will add all the actions once WordPress
* has initialized.
*/
function jm_add_actions()
{
add_action('woocommerce_checkout_order_processed', 'jm_has_single_event', 10, 2)
}
/**
* This checks if the user who just checked out
* signed up for a single's event
*
* @param order_id Represents the ID of the order
* @param posted Represents the contents posted...(not useful)
*/
function jm_has_single_event( $order_id, $posted )
{
$current_order = new WC_Order( $order_id );
$checkout_items = $current_order->get_items();
foreach( $checkout_items as $item )
{
$product_categories = $item->get_categories();
if( contains( $product_categories, 'singles-events' )
// Add to mail chimp...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment