Created
February 8, 2013 19:08
-
-
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.
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 | |
/** | |
* This is a simple snippet showing a hypothetical | |
* solution for adding users to a mailing list in | |
* mailchimp. | |
* | |
* @author Jonathon McDonald <[email protected]> | |
*/ | |
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