function eStore_aweber_new_signup_user($full_target_list_name, $fname, $lname, $email_to_subscribe) { eStore_payment_debug("Attempting to signup the user via AWeber API", true); $wp_eStore_config = WP_eStore_Config::getInstance(); $eStore_aweber_access_keys = $wp_eStore_config->getValue('eStore_aweber_access_keys'); if (empty($eStore_aweber_access_keys['consumer_key'])) { eStore_payment_debug("Missing AWeber access keys! You need to first make a conntect before you can use this API", false); return; } //wp_eStore_write_debug_array($eStore_aweber_access_keys,true); if (!class_exists('AWeberAPI')) { //TODO - change the class name to "eStore_AWeberAPI" to avoid conflict with others include_once 'lib/auto-responder/aweber_api/aweber_api.php'; eStore_payment_debug("AWeber API library inclusion succeeded.", true); } else { eStore_payment_debug("AWeber API library is already included from another plugin.", true); } $aweber = new AWeberAPI($eStore_aweber_access_keys['consumer_key'], $eStore_aweber_access_keys['consumer_secret']); $account = $aweber->getAccount($eStore_aweber_access_keys['access_key'], $eStore_aweber_access_keys['access_secret']); //Get Aweber account $account_id = $account->id; $mylists = $account->lists; eStore_payment_debug("AWeber account retrieved. Account ID: " . $account_id, true); $target_list_name = str_replace("@aweber.com", "", $full_target_list_name); eStore_payment_debug("Attempting to signup the user to the AWeber list: " . $target_list_name, true); $list_name_found = false; foreach ($mylists as $list) { if ($list->name == $target_list_name) { $list_name_found = true; try { //Create a subscriber $params = array('email' => $email_to_subscribe, 'name' => $fname . ' ' . $lname); $subscribers = $list->subscribers; $new_subscriber = $subscribers->create($params); eStore_payment_debug("User with email address " . $email_to_subscribe . " was added to the AWeber list: " . $target_list_name, true); } catch (Exception $exc) { eStore_payment_debug("Failed to complete the AWeber signup! Error Details Below.", false); wp_eStore_write_debug_array($exc, true); } } } if (!$list_name_found) { eStore_payment_debug("Error! Could not find the AWeber list (" . $full_target_list_name . ") in your AWeber Account! Please double check your list name value for typo.", false); } }
function wp_eStore_handle_retrieve_cart_action($action) { eStore_payment_debug('Processing retrieve cart action...', true); $cart_id = strip_tags($_REQUEST['cart_id']); if (empty($cart_id)) { eStore_payment_debug('Error! Cart ID is empty! Cannot process this request', false); echo json_encode(array('reply_action' => $action, 'status' => 'error', 'code' => 'ESTORE_AJAX_01', 'details' => 'Cart ID is empty!')); exit; } eStore_payment_debug('Retrieving previously saved cart... Cart ID: ' . $cart_id, true); $eStore_cart = wp_eStore_get_cart_details_from_db($cart_id); if ($eStore_cart === "-1") { eStore_payment_debug('Error! Failed to retrieve cart for the given cart ID!', false); echo json_encode(array('reply_action' => $action, 'status' => 'error', 'code' => 'ESTORE_AJAX_02', 'details' => 'Failed to retrieve cart for the given cart ID!')); exit; } eStore_payment_debug('Loading cart into session...', true); wp_eStore_load_cart_class_to_session($eStore_cart); wp_eStore_write_debug_array($_SESSION['eStore_cart'], true); echo json_encode(array('reply_action' => $action, 'status' => 'success', 'ID' => $cart_id)); exit; }