function signup_pre_redirect_to_cart($args = array())
 {
     global $mp;
     if (!$mp) {
         return;
     }
     $course_id = 0;
     if (!empty($args)) {
         $course_id = isset($args['course_id']) ? $args['course_id'] : false;
     } else {
         $course_id = !empty($_POST['course_id']) ? (int) $_POST['course_id'] : false;
     }
     $course = new Course($course_id);
     $product_id = $course->mp_product_id();
     // Try some MP alternatives
     $product_id = empty($product_id) ? (int) get_post_meta($course_id, 'mp_product_id', true) : $product_id;
     $product_id = empty($product_id) ? (int) get_post_meta($course_id, 'marketpress_product', true) : $product_id;
     // Set ID's to be used in final step of checkout
     $cookie_id = 'cp_checkout_keys_' . COOKIEHASH;
     $post_keys = array((int) $product_id, (int) $course_id);
     $expire = time() + 2592000;
     //1 month expire
     setcookie($cookie_id, serialize($post_keys), $expire, COOKIEPATH, COOKIE_DOMAIN);
     $_COOKIE[$cookie_id] = serialize($post_keys);
     // Add course to cart
     $product = get_post($product_id);
     $quantity = 1;
     $variation = 0;
     // $cart = $mp->get_cart_cookie();
     switch (CoursePress_MarketPress_Integration::get_base()) {
         case '3.0':
             $cart = MP_Cart::get_instance();
             $cart->add_item($product_id);
             break;
         case '2.0':
             $cart = array();
             // remove all cart items
             $cart[$product_id][$variation] = $quantity;
             $mp->set_cart_cookie($cart);
             break;
     }
 }