/** * When a user is renewing their key from a renewal URL, after they login, * immediately add the product to the cart. * * @since 1.0 * * @param string $username * @param \WP_User $user */ public function add_product_to_cart_on_login($username, $user) { if (!isset($_POST['renew_key'])) { return; } $key = itelic_get_key($_POST['renew_key']); if (!$key) { return; } if ($key->get_customer()->id != $user->ID) { return; } it_exchange_add_product_to_shopping_cart($key->get_product()->ID); $this->update_cache_data(array("p{$key->get_product()->ID}" => $key->get_key())); }
/** * AJAX function, to set the iT Exchange product in the cart */ function iditexch_add_product_to_cart() { $product_id = $_POST['product_id']; // Adds the product to the cart. second arg is optional and designates the quantity. it_exchange_add_product_to_shopping_cart($product_id, 1); }