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; } }
public static function course_product_images_meta($value, $post_id, $meta_key, $single) { if ('mp_product_images' === $meta_key && !self::$looping) { // Avoid looping, because we're calling this meta again. self::$looping = true; $product_images = get_post_meta($post_id, $meta_key, $single); if (empty($product_images)) { $course_id = !empty($post_id) ? get_post_meta($post_id, 'course_id', true) : 0; $featured_url = !empty($course_id) ? get_post_meta($course_id, 'featured_url', true) : ''; $admin_edit = isset($_GET['action']) && 'edit' === $_GET['action']; $value = !empty($featured_url) && !$admin_edit ? $featured_url : $value; } // No longer looping self::$looping = false; } return $value; }
?> </label> <?php if (!CoursePress_Capabilities::is_pro()) { echo sprintf(__('To start selling your course, you will need to activate the MarketPress Lite plugin: <br /> %s<br /><br />' . 'If you require other payment gateways, you will need to upgrade to %s.', 'cp'), '<a target="_blank" href="' . admin_url('admin.php?page=' . $this->screen_base . '_settings' . '&tab=cp-marketpress') . '">' . __('Begin Activating MarketPress Lite', 'cp') . '</a>', '<a target="_blank" href="https://premium.wpmudev.org/project/e-commerce/">' . __('MarketPress', 'cp') . '</a>'); } else { echo sprintf(__('The full version of MarketPress has been bundled with %s.<br />' . 'To start selling your course, you will need to activate MarketPress: <br /> %s<br /><br />', 'cp'), 'CoursePress Pro', '<a target="_blank" href="' . admin_url('admin.php?page=' . $this->screen_base . '_settings' . '&tab=cp-marketpress') . '">' . __('Begin Activating MarketPress', 'cp') . '</a>'); } ?> </div> </div> <!-- cp-marketpress-not-active --> <?php } if (current_user_can('manage_options') || !current_user_can('manage_options') && $gateways) { echo CoursePress_MarketPress_Integration::product_settings('', $course_id); } ?> <!-- cp-markertpress-is-active --> <!--_e('Please ask administrator to enable at least one payment gateway.', 'cp');--> </div> <?php // End check for Campus. } } ?> <?php // END /////////////////////////////// ?>