Skip to content

Instantly share code, notes, and snippets.

View alexhammerschmied's full-sized avatar

Alex Hammerschmied alexhammerschmied

View GitHub Profile
@codelance
codelance / config.php
Last active April 14, 2018 07:27
Add mailchimp subscribe to woocommerce checkout.
/**
* Subscribe User to MailChimp
*/
function wooms_mailchimp_subscribe_user($order_id,$posted){
if(!empty($_POST['wooms_susbscribe']) && $_POST['wooms_susbscribe'] == '1'){
try{
$email = $posted['billing_email'];
$merge_vars = array('FNAME' => $posted['billing_first_name'],'LNAME' => $posted['billing_last_name']);
$api = new MCAPI(mailchimp_api_key);
@tharmann
tharmann / functions.php
Last active January 11, 2017 21:09
Add a checkbox to WooCommerce order form to process MailChimp API 3.0 list member subscriptions (placed after T&C checkbox if enabled on order form)
<?php
//add action to process mailchimp signup if checked
function mc_checkout_field_process() {
//only run the following if the option to subscribe has been selected
if ( $_POST['mc-subscribe'] == 'on' ) {
//retrieve email, first, and last name from form
$email = $_POST['billing_email'];
$first_name = $_POST['billing_first_name'];
$last_name = $_POST['billing_last_name'];