コード例 #1
0
/**
 * Shopping Cart
 *
 * @access      public
 * @since       1.0
 * @return      string
*/
function edd_shopping_cart($echo = false)
{
    global $edd_options;
    ob_start();
    ?>

	<?php 
    do_action('edd_before_cart');
    ?>
	<ul class="edd-cart">
	<?php 
    $cart_items = edd_get_cart_contents();
    if ($cart_items) {
        foreach ($cart_items as $key => $item) {
            echo edd_get_cart_item_template($key, $item, false);
        }
        echo '<li class="cart_item edd_checkout"><a href="' . edd_get_checkout_uri() . '">' . __('Checkout', 'edd') . '</a></li>';
    } else {
        echo '<li class="cart_item empty">' . edd_empty_cart_message() . '</li>';
        echo '<li class="cart_item edd_checkout" style="display:none;"><a href="' . edd_get_checkout_uri() . '">' . __('Checkout', 'edd') . '</a></li>';
    }
    ?>
	</ul>
	<?php 
    do_action('edd_after_cart');
    if ($echo) {
        echo ob_get_clean();
    } else {
        return ob_get_clean();
    }
}
コード例 #2
0
/**
 * Load Scripts
 *
 * Enqueues the required scripts.
 *
 * @access      private
 * @since       1.0
 * @return      void
*/
function edd_load_scripts()
{
    global $edd_options, $post;
    wp_enqueue_script('jquery');
    // Get position in cart of current download
    if (isset($post->ID)) {
        $position = edd_get_item_position_in_cart($post->ID);
    }
    // Load AJAX scripts, if enabled
    if (edd_is_ajax_enabled()) {
        wp_enqueue_script('edd-ajax', EDD_PLUGIN_URL . 'assets/js/edd-ajax.js', array('jquery'), EDD_VERSION);
        wp_localize_script('edd-ajax', 'edd_scripts', array('ajaxurl' => edd_get_ajax_url(), 'ajax_nonce' => wp_create_nonce('edd_ajax_nonce'), 'no_discount' => __('Please enter a discount code', 'edd'), 'discount_applied' => __('Discount Applied', 'edd'), 'no_email' => __('Please enter an email address before applying a discount code', 'edd'), 'no_username' => __('Please enter a username before applying a discount code', 'edd'), 'position_in_cart' => isset($position) ? $position : -1, 'already_in_cart_message' => __('You have already added this item to your cart', 'edd'), 'empty_cart_message' => __('Your cart is empty', 'edd'), 'loading' => __('Loading', 'edd'), 'ajax_loader' => EDD_PLUGIN_URL . 'assets/images/loading.gif', 'checkout_page' => edd_get_checkout_uri(), 'permalinks' => get_option('permalink_structure') ? '1' : '0'));
    }
    // Load jQuery validation
    if (isset($edd_options['jquery_validation']) && edd_is_checkout()) {
        wp_enqueue_script('jquery-validation', EDD_PLUGIN_URL . 'assets/js/jquery.validate.min.js');
        wp_enqueue_script('edd-validation', EDD_PLUGIN_URL . 'assets/js/form-validation.js', array('jquery', 'jquery-validation'), EDD_VERSION);
        $required = array('firstname' => true, 'lastname' => true);
        wp_localize_script('edd-validation', 'edd_scripts_validation', apply_filters('edd_scripts_validation', $required));
    }
    if (edd_is_checkout()) {
        if (edd_is_cc_verify_enabled()) {
            wp_enqueue_script('creditCardValidator', EDD_PLUGIN_URL . 'assets/js/jquery.creditCardValidator.js', array('jquery'), EDD_VERSION);
        }
        wp_enqueue_script('edd-checkout-global', EDD_PLUGIN_URL . 'assets/js/edd-checkout-global.js', array('jquery'), EDD_VERSION);
        wp_localize_script('edd-checkout-global', 'edd_global_vars', array('currency_sign' => edd_currency_filter(''), 'currency_pos' => isset($edd_options['currency_position']) ? $edd_options['currency_position'] : 'before', 'no_gateway' => __('Please select a payment method', 'edd')));
    }
}
コード例 #3
0
/**
 * Show cart link and quantity count in header if the cart has contents.
 *
 * The ".edd-cart-quantity" class is needed in order for the quantity to be
 * updated dynamically via AJAX.
 *
 * @todo  Add cart link to mobile navigation bar.
 *
 * @since 1.0.0
 */
function huesos_edd_show_header_cart_link()
{
    if (!edd_get_cart_contents()) {
        return;
    }
    printf('<p class="cart-quantity"><a class="button" href="%1$s">%2$s (<span class="edd-cart-quantity">%3$s</span>)</a></p>', esc_url(edd_get_checkout_uri()), esc_html__('Cart', 'huesos'), esc_html(edd_get_cart_quantity()));
}
コード例 #4
0
ファイル: actions.php プロジェクト: nguyenthai2010/ngocshop
/**
 * Process the Add all to cart request
 *
 * @since 1.0
 *
 * @param $data
 */
function edd_wl_process_purchase_all($data)
{
    $cart_items = edd_wl_add_all_to_cart($data['list_id']);
    // redirect straight to checkout with items added
    wp_redirect(edd_get_checkout_uri());
    edd_die();
}
コード例 #5
0
ファイル: scripts.php プロジェクト: nguyenthai2010/ngocshop
/**
 * Load Scripts
 *
 * Enqueues the required scripts.
 *
 * @since 1.0
 * @global $post
 * @return void
 */
function edd_load_scripts()
{
    global $post;
    $js_dir = EDD_PLUGIN_URL . 'assets/js/';
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    // Get position in cart of current download
    if (isset($post->ID)) {
        $position = edd_get_item_position_in_cart($post->ID);
    }
    if (edd_is_checkout()) {
        if (edd_is_cc_verify_enabled()) {
            wp_register_script('creditCardValidator', $js_dir . 'jquery.creditCardValidator' . $suffix . '.js', array('jquery'), EDD_VERSION);
            wp_enqueue_script('creditCardValidator');
        }
        wp_register_script('edd-checkout-global', $js_dir . 'edd-checkout-global' . $suffix . '.js', array('jquery'), EDD_VERSION);
        wp_enqueue_script('edd-checkout-global');
        wp_localize_script('edd-checkout-global', 'edd_global_vars', apply_filters('edd_global_checkout_script_vars', array('ajaxurl' => edd_get_ajax_url(), 'checkout_nonce' => wp_create_nonce('edd_checkout_nonce'), 'currency_sign' => edd_currency_filter(''), 'currency_pos' => edd_get_option('currency_position', 'before'), 'no_gateway' => __('Please select a payment method', 'edd'), 'no_discount' => __('Please enter a discount code', 'edd'), 'enter_discount' => __('Enter discount', 'edd'), 'discount_applied' => __('Discount Applied', 'edd'), 'no_email' => __('Please enter an email address before applying a discount code', 'edd'), 'no_username' => __('Please enter a username before applying a discount code', 'edd'), 'purchase_loading' => __('Please Wait...', 'edd'), 'complete_purchase' => __('Purchase', 'edd'), 'taxes_enabled' => edd_use_taxes() ? '1' : '0', 'edd_version' => EDD_VERSION)));
    }
    // Load AJAX scripts, if enabled
    if (!edd_is_ajax_disabled()) {
        wp_register_script('edd-ajax', $js_dir . 'edd-ajax' . $suffix . '.js', array('jquery'), EDD_VERSION);
        wp_enqueue_script('edd-ajax');
        wp_localize_script('edd-ajax', 'edd_scripts', apply_filters('edd_ajax_script_vars', array('ajaxurl' => edd_get_ajax_url(), 'position_in_cart' => isset($position) ? $position : -1, 'already_in_cart_message' => __('You have already added this item to your cart', 'edd'), 'empty_cart_message' => __('Your cart is empty', 'edd'), 'loading' => __('Loading', 'edd'), 'select_option' => __('Please select an option', 'edd'), 'ajax_loader' => set_url_scheme(EDD_PLUGIN_URL . 'assets/images/loading.gif', 'relative'), 'is_checkout' => edd_is_checkout() ? '1' : '0', 'default_gateway' => edd_get_default_gateway(), 'redirect_to_checkout' => edd_straight_to_checkout() || edd_is_checkout() ? '1' : '0', 'checkout_page' => edd_get_checkout_uri(), 'permalinks' => get_option('permalink_structure') ? '1' : '0', 'quantities_enabled' => edd_item_quantities_enabled(), 'taxes_enabled' => edd_use_taxes() ? '1' : '0')));
    }
}
コード例 #6
0
/**
 * Get the purchase form
 *
 * @access      private
 * @since       1.4
 * @return      string
*/
function edd_show_purchase_form()
{
    global $edd_options;
    $payment_mode = edd_get_chosen_gateway();
    $form_action = esc_url(edd_get_checkout_uri('payment-mode=' . $payment_mode));
    do_action('edd_before_purchase_form');
    ?>

	<form id="edd_purchase_form" action="<?php 
    echo $form_action;
    ?>
" method="POST">

		<?php 
    do_action('edd_purchase_form_top');
    if (edd_can_checkout()) {
        ?>

			<?php 
        if (isset($edd_options['show_register_form']) && !is_user_logged_in() && !isset($_GET['login'])) {
            ?>
				<div id="edd_checkout_login_register"><?php 
            do_action('edd_purchase_form_register_fields');
            ?>
</div>
			<?php 
        } elseif (isset($edd_options['show_register_form']) && !is_user_logged_in() && isset($_GET['login'])) {
            ?>
				<div id="edd_checkout_login_register"><?php 
            do_action('edd_purchase_form_login_fields');
            ?>
</div>
			<?php 
        }
        ?>

			<?php 
        if (!isset($_GET['login']) && is_user_logged_in() || !isset($edd_options['show_register_form'])) {
            do_action('edd_purchase_form_after_user_info');
        }
        do_action('edd_purchase_form_before_cc_form');
        // load the credit card form and allow gateways to load their own if they wish
        if (has_action('edd_' . $payment_mode . '_cc_form')) {
            do_action('edd_' . $payment_mode . '_cc_form');
        } else {
            do_action('edd_cc_form');
        }
        do_action('edd_purchase_form_after_cc_form');
    } else {
        // can't checkout
        do_action('edd_purchase_form_no_access');
    }
    do_action('edd_purchase_form_bottom');
    ?>

	</form> <?php 
    do_action('edd_after_purchase_form');
}
コード例 #7
0
/**
 * Process the Add to Cart request
 *
 * @since 1.0
 * @return void
 */
function edd_process_add_to_cart($data)
{
    $download_id = $data['download_id'];
    $options = isset($data['edd_options']) ? $data['edd_options'] : array();
    $cart = edd_add_to_cart($download_id, $options);
    if (edd_straight_to_checkout() && !edd_is_checkout()) {
        wp_redirect(edd_get_checkout_uri(), 303);
        edd_die();
    }
}
コード例 #8
0
/**
 * Prevents items from being added to the cart multiple times
 *
 */
function pw_edd_prevent_duplicate_cart_items($download_id, $options)
{
    if (edd_item_in_cart($download_id, $options)) {
        if (edd_is_ajax_enabled()) {
            die('1');
        } else {
            wp_redirect(edd_get_checkout_uri());
            exit;
        }
    }
}
コード例 #9
0
/**
 * Get Checkout Form
 *
 * @since 1.0
 * @return string
 */
function edd_checkout_form()
{
    $payment_mode = edd_get_chosen_gateway();
    $form_action = esc_url(edd_get_checkout_uri('payment-mode=' . $payment_mode));
    ob_start();
    echo '<div id="edd_checkout_wrap">';
    if (edd_get_cart_contents() || edd_cart_has_fees()) {
        edd_checkout_cart();
        ?>
			<div id="edd_checkout_form_wrap" class="edd_clearfix">
				<?php 
        do_action('edd_before_purchase_form');
        ?>
				<form id="edd_purchase_form" class="edd_form" action="<?php 
        echo $form_action;
        ?>
" method="POST">
					<?php 
        /**
         * Hooks in at the top of the checkout form
         *
         * @since 1.0
         */
        do_action('edd_checkout_form_top');
        if (edd_show_gateways()) {
            do_action('edd_payment_mode_select');
        } else {
            do_action('edd_purchase_form');
        }
        /**
         * Hooks in at the bottom of the checkout form
         *
         * @since 1.0
         */
        do_action('edd_checkout_form_bottom');
        ?>
				</form>
				<?php 
        do_action('edd_after_purchase_form');
        ?>
			</div><!--end #edd_checkout_form_wrap-->
		<?php 
    } else {
        /**
         * Fires off when there is nothing in the cart
         *
         * @since 1.0
         */
        do_action('edd_cart_empty');
    }
    echo '</div><!--end #edd_checkout_wrap-->';
    return ob_get_clean();
}
コード例 #10
0
ファイル: idf.php プロジェクト: xop32/ignitiondeck
function idf_lightbox()
{
    wp_register_script('idf-lite', plugins_url('js/idf-lite.js', __FILE__));
    wp_register_script('idf', plugins_url('js/idf.js', __FILE__));
    wp_register_style('magnific', plugins_url('lib/magnific/magnific.css', __FILE__));
    wp_register_script('magnific', plugins_url('lib/magnific/magnific.js', __FILE__));
    wp_register_style('idf', plugins_url('css/idf.css', __FILE__));
    wp_enqueue_script('jquery');
    if (idf_enable_checkout()) {
        $checkout_url = '';
        $platform = idf_platform();
        if ($platform == 'wc' && !is_admin()) {
            if (class_exists('WooCommerce')) {
                global $woocommerce;
                $checkout_url = $woocommerce->cart->get_checkout_url();
            }
        } else {
            if ($platform == 'edd' && class_exists('Easy_Digital_Downloads') && !is_admin()) {
                $checkout_url = edd_get_checkout_uri();
            } else {
                if ($platform == 'itexchange' && class_exists('IT_Exchange') && !is_admin()) {
                    // Getting checkout URL for iT exchange product
                    global $post;
                    $post_id = $post->ID;
                    $checkout_links = array();
                    // Get levels and setting url for each level
                    $number_of_levels = get_post_meta($post_id, "ign_product_level_count", true);
                    for ($i = 1; $i <= $number_of_levels; $i++) {
                        $iditexch_project_id = get_post_meta($post_id, 'iditexch_level_pairing_' . $i, true);
                        $checkout_links[$i]['url'] = get_permalink($iditexch_project_id);
                        $checkout_links[$i]['product'] = $iditexch_project_id;
                    }
                    $checkout_url = json_encode($checkout_links);
                }
            }
        }
        wp_enqueue_style('magnific');
        wp_enqueue_style('idf');
        wp_enqueue_script('idf');
        wp_enqueue_script('magnific');
        wp_localize_script('idf', 'idf_platform', $platform);
        // Let's set the ajax url
        $idf_ajaxurl = site_url('/wp-admin/admin-ajax.php');
        wp_localize_script('idf', 'idf_siteurl', site_url());
        wp_localize_script('idf', 'idf_ajaxurl', $idf_ajaxurl);
        if (isset($checkout_url)) {
            wp_localize_script('idf', 'idf_checkout_url', $checkout_url);
        }
    } else {
        wp_enqueue_script('idf-lite');
    }
}
コード例 #11
0
 /**
  * Parse the URL for the package downloader
  *
  * @since  3.2.4
  * @return array Array of parsed url information
  */
 private function parse_url()
 {
     if (false === stristr($_SERVER['REQUEST_URI'], 'edd-sl/package_download')) {
         return false;
         // Not a package download request
     }
     $data = array();
     $url_parts = parse_url($_SERVER['REQUEST_URI']);
     $paths = array_values(explode('/', $url_parts['path']));
     $token = end($paths);
     $values = explode(':', base64_decode($token));
     if (count($values) !== 5) {
         wp_die(__('Invalid token supplied', 'edd_sl'), __('Error', 'edd_sl'), array('response' => 401));
     }
     $expires = $values[0];
     $license_key = $values[1];
     $download_id = (int) $values[2];
     $url = str_replace('@', ':', $values[4]);
     if (!edd_software_licensing()->is_download_id_valid_for_license($download_id, $license_key)) {
         wp_die(__('Invalid license supplied', 'edd_sl'), __('Error', 'edd_sl'), array('response' => 401));
     }
     $license_check_args = array('url' => $url, 'key' => $license_key, 'item_id' => $download_id);
     $license_status = edd_software_licensing()->check_license($license_check_args);
     switch ($license_status) {
         case 'expired':
             $renewal_link = add_query_arg('edd_license_key', $license_key, edd_get_checkout_uri());
             wp_die(sprintf(__('Your license has expired, please <a href="%s" title="Renew your license">renew it</a> to install this update.', 'edd_sl'), $renewal_link), __('Error', 'edd_sl'), array('response' => 401));
             break;
         case 'inactive':
         case 'site_inactive':
             wp_die(__('Your license has not been activated for this domain, please activate it first.', 'edd_sl'), __('Error', 'edd_sl'), array('response' => 401));
             break;
         case 'disabled':
             wp_die(__('Your license has been disabled.', 'edd_sl'), __('Error', 'edd_sl'), array('response' => 401));
             break;
         case 'valid':
             break;
         default:
             wp_die(__('Your license could not be validated.', 'edd_sl'), __('Error', 'edd_sl'), array('response' => 401));
             break;
     }
     $download_name = get_the_title($download_id);
     $file_key = get_post_meta($download_id, '_edd_sl_upgrade_file_key', true);
     $hash = md5($download_name . $file_key . $download_id . $license_key . $expires);
     if (!hash_equals($hash, $values[3])) {
         wp_die(__('Provided hash does not validate.', 'edd_sl'), __('Error', 'edd_sl'), array('response' => 401));
     }
     $data = array('expires' => $expires, 'license' => $license_key, 'id' => $download_id, 'key' => $hash);
     return $data;
 }
コード例 #12
0
/**
 * Process cart endpoints
 *
 * Listens for add / remove requests
 *
 * @access      private
 * @since       1.3.4
 * @return      void
*/
function edd_process_cart_endpoints()
{
    global $wp_query;
    // adds an item to the cart with a /edd-add/# URL
    if (isset($wp_query->query_vars['edd-add'])) {
        $download_id = absint($wp_query->query_vars['edd-add']);
        $cart = edd_add_to_cart($download_id, array());
        wp_redirect(edd_get_checkout_uri());
        exit;
    }
    // removes an item from the cart with a /edd-remove/# URL
    if (isset($wp_query->query_vars['edd-remove'])) {
        $cart_key = absint($wp_query->query_vars['edd-remove']);
        $cart = edd_remove_from_cart($cart_key);
        wp_redirect(edd_get_checkout_uri());
        exit;
    }
}
コード例 #13
0
/**
 * Get Checkout Form
 *
 * @since 1.0
 * @global $edd_options Array of all the EDD options
 * @global $user_ID ID of current logged in user
 * @global $post Current Post Object
 * @return string
 */
function edd_checkout_form()
{
    global $edd_options, $user_ID, $post;
    $payment_mode = edd_get_chosen_gateway();
    $form_action = esc_url(edd_get_checkout_uri('payment-mode=' . $payment_mode));
    ob_start();
    echo '<div id="edd_checkout_wrap">';
    if (edd_get_cart_contents() || edd_cart_has_fees()) {
        edd_checkout_cart();
        ?>
			<div id="edd_checkout_form_wrap" class="edd_clearfix">
				<?php 
        do_action('edd_before_purchase_form');
        ?>
				<form id="edd_purchase_form" class="edd_form" action="<?php 
        echo $form_action;
        ?>
" method="POST">
					<?php 
        do_action('edd_checkout_form_top');
        if (edd_show_gateways()) {
            do_action('edd_payment_mode_select');
        } else {
            do_action('edd_purchase_form');
        }
        do_action('edd_checkout_form_bottom');
        ?>
				</form>
				<?php 
        do_action('edd_after_purchase_form');
        ?>
			</div><!--end #edd_checkout_form_wrap-->
		<?php 
    } else {
        do_action('edd_cart_empty');
    }
    echo '</div><!--end #edd_checkout_wrap-->';
    return ob_get_clean();
}
コード例 #14
0
/**
 * Process deposit
 *
 * @since       1.0.0
 * @return      void
 */
function edd_wallet_process_deposit()
{
    // Verify the nonce
    if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'edd-wallet-deposit-nonce')) {
        wp_die(__('Nonce verification failed', 'edd-wallet'), __('Error', 'edd-wallet'), array('response' => 403));
    }
    // Make sure the cart is empty
    edd_empty_cart();
    $value = $_POST['edd_wallet_deposit_amount'];
    if ($value == 'custom') {
        $value = $_POST['edd_wallet_custom_deposit'];
    }
    // Setup the fee label
    $label = edd_get_option('edd_wallet_deposit_description', __('Deposit to wallet', 'edd-wallet'));
    $label = str_replace('{val}', edd_currency_filter(edd_format_amount($value)), $label);
    // Setup the fee (product) for the deposit
    $fee = array('amount' => $value, 'label' => $label, 'type' => 'item', 'no_tax' => true, 'id' => 'edd-wallet-deposit');
    EDD()->fees->add_fee($fee);
    // Redirect to checkout
    wp_redirect(edd_get_checkout_uri(), 303);
    edd_die();
}
コード例 #15
0
/**
 * Redirect to EDD checkout after form submission
 *
 * @since 1.0
 */
function ninja_forms_edd_checkout_redirect()
{
    global $ninja_forms_processing;
    // get settings
    $settings = $ninja_forms_processing->get_all_form_settings();
    // is ajax enabled
    $ajax_enabled = isset($ninja_forms_processing->data['form']['ajax']) ? $ninja_forms_processing->data['form']['ajax'] : '';
    // send this form to EDD checkout?
    $send_to_edd = isset($settings['ninja_forms_send_to_edd']) ? $settings['ninja_forms_send_to_edd'] : '';
    // return if this form shouldn't send to EDD checkout
    if (!$send_to_edd) {
        return;
    }
    if ($ajax_enabled) {
        ninja_forms_edd_process_form();
        return;
    }
    // process form
    ninja_forms_edd_process_form();
    // redirect non-ajax form
    wp_redirect(edd_get_checkout_uri());
    exit;
}
コード例 #16
0
ファイル: idf.php プロジェクト: mariuskarma/wp
function idf_lightbox()
{
    wp_register_script('idf-lite', plugins_url('js/idf-lite.js', __FILE__));
    wp_register_script('idf', plugins_url('js/idf.js', __FILE__));
    wp_register_style('magnific', plugins_url('lib/magnific/magnific.css', __FILE__));
    wp_register_script('magnific', plugins_url('lib/magnific/magnific.js', __FILE__));
    wp_register_style('idf', plugins_url('css/idf.css', __FILE__));
    wp_enqueue_script('jquery');
    if (idf_enable_checkout()) {
        $platform = idf_platform();
        if ($platform == 'wc' && class_exists('WooCommerce') && !is_admin()) {
            global $woocommerce;
            $checkout_url = $woocommerce->cart->get_checkout_url();
        } else {
            if ($platform == 'edd' && class_exists('Easy_Digital_Downloads') && !is_admin()) {
                $checkout_url = edd_get_checkout_uri();
            }
        }
        wp_enqueue_style('magnific');
        wp_enqueue_style('idf');
        wp_enqueue_script('idf');
        wp_enqueue_script('magnific');
        wp_localize_script('idf', 'idf_platform', $platform);
        // Let's set the ajax url
        $idf_ajaxurl = site_url('/wp-admin/admin-ajax.php');
        wp_localize_script('idf', 'idf_siteurl', site_url());
        wp_localize_script('idf', 'idf_ajaxurl', $idf_ajaxurl);
        if (isset($checkout_url)) {
            wp_localize_script('idf', 'idf_checkout_url', $checkout_url);
        }
    } else {
        wp_enqueue_script('idf-lite');
    }
    wp_register_style('magnific', plugins_url('lib/magnific/magnific.css', __FILE__));
    wp_enqueue_style('magnific');
}
コード例 #17
0
/**
 * Get Purchase Link
 *
 * Builds a Purchase link for a specified download based on arguments passed.
 * This function is used all over EDD to generate the Purchase or Add to Cart
 * buttons. If no arguments are passed, the function uses the defaults that have
 * been set by the plugin. The Purchase link is built for simple and variable
 * pricing and filters are available throughout the function to override
 * certain elements of the function.
 *
 * $download_id = null, $link_text = null, $style = null, $color = null, $class = null
 *
 * @since 1.0
 * @param array $args Arguments for display
 * @return string $purchase_form
 */
function edd_get_purchase_link($args = array())
{
    global $post, $edd_displayed_form_ids;
    $purchase_page = edd_get_option('purchase_page', false);
    if (!$purchase_page || $purchase_page == 0) {
        edd_set_error('set_checkout', sprintf(__('No checkout page has been configured. Visit <a href="%s">Settings</a> to set one.', 'easy-digital-downloads'), admin_url('edit.php?post_type=download&page=edd-settings')));
        edd_print_errors();
        return false;
    }
    $post_id = is_object($post) ? $post->ID : 0;
    $button_behavior = edd_get_download_button_behavior($post_id);
    $defaults = apply_filters('edd_purchase_link_defaults', array('download_id' => $post_id, 'price' => (bool) true, 'price_id' => isset($args['price_id']) ? $args['price_id'] : false, 'direct' => $button_behavior == 'direct' ? true : false, 'text' => $button_behavior == 'direct' ? edd_get_option('buy_now_text', __('Buy Now', 'easy-digital-downloads')) : edd_get_option('add_to_cart_text', __('Purchase', 'easy-digital-downloads')), 'style' => edd_get_option('button_style', 'button'), 'color' => edd_get_option('checkout_color', 'blue'), 'class' => 'edd-submit'));
    $args = wp_parse_args($args, $defaults);
    // Override the stright_to_gateway if the shop doesn't support it
    if (!edd_shop_supports_buy_now()) {
        $args['direct'] = false;
    }
    $download = new EDD_Download($args['download_id']);
    if (empty($download->ID)) {
        return false;
    }
    if ('publish' !== $download->post_status && !current_user_can('edit_product', $download->ID)) {
        return false;
        // Product not published or user doesn't have permission to view drafts
    }
    // Override color if color == inherit
    $args['color'] = $args['color'] == 'inherit' ? '' : $args['color'];
    $options = array();
    $variable_pricing = $download->has_variable_prices();
    $data_variable = $variable_pricing ? ' data-variable-price="yes"' : 'data-variable-price="no"';
    $type = $download->is_single_price_mode() ? 'data-price-mode=multi' : 'data-price-mode=single';
    $show_price = $args['price'] && $args['price'] !== 'no';
    $data_price_value = 0;
    $price = false;
    if ($variable_pricing && false !== $args['price_id']) {
        $price_id = $args['price_id'];
        $prices = $download->prices;
        $options['price_id'] = $args['price_id'];
        $found_price = isset($prices[$price_id]) ? $prices[$price_id]['amount'] : false;
        $data_price_value = $found_price;
        if ($show_price) {
            $price = $found_price;
        }
    } elseif (!$variable_pricing) {
        $data_price_value = $download->price;
        if ($show_price) {
            $price = $download->price;
        }
    }
    $args['display_price'] = $data_price_value;
    $data_price = 'data-price="' . $data_price_value . '"';
    $button_text = !empty($args['text']) ? '&nbsp;&ndash;&nbsp;' . $args['text'] : '';
    if (false !== $price) {
        if (0 == $price) {
            $args['text'] = __('Free', 'easy-digital-downloads') . $button_text;
        } else {
            $args['text'] = edd_currency_filter(edd_format_amount($price)) . $button_text;
        }
    }
    if (edd_item_in_cart($download->ID, $options) && (!$variable_pricing || !$download->is_single_price_mode())) {
        $button_display = 'style="display:none;"';
        $checkout_display = '';
    } else {
        $button_display = '';
        $checkout_display = 'style="display:none;"';
    }
    // Collect any form IDs we've displayed already so we can avoid duplicate IDs
    if (isset($edd_displayed_form_ids[$download->ID])) {
        $edd_displayed_form_ids[$download->ID]++;
    } else {
        $edd_displayed_form_ids[$download->ID] = 1;
    }
    $form_id = !empty($args['form_id']) ? $args['form_id'] : 'edd_purchase_' . $download->ID;
    // If we've already generated a form ID for this download ID, apped -#
    if ($edd_displayed_form_ids[$download->ID] > 1) {
        $form_id .= '-' . $edd_displayed_form_ids[$download->ID];
    }
    $args = apply_filters('edd_purchase_link_args', $args);
    ob_start();
    ?>
	<form id="<?php 
    echo $form_id;
    ?>
" class="edd_download_purchase_form edd_purchase_<?php 
    echo absint($download->ID);
    ?>
" method="post">

		<?php 
    do_action('edd_purchase_link_top', $download->ID, $args);
    ?>

		<div class="edd_purchase_submit_wrapper">
			<?php 
    $class = implode(' ', array($args['style'], $args['color'], trim($args['class'])));
    if (!edd_is_ajax_disabled()) {
        echo '<a href="#" class="edd-add-to-cart ' . esc_attr($class) . '" data-action="edd_add_to_cart" data-download-id="' . esc_attr($download->ID) . '" ' . $data_variable . ' ' . $type . ' ' . $data_price . ' ' . $button_display . '><span class="edd-add-to-cart-label">' . $args['text'] . '</span> <span class="edd-loading"><i class="edd-icon-spinner edd-icon-spin"></i></span></a>';
    }
    echo '<input type="submit" class="edd-add-to-cart edd-no-js ' . esc_attr($class) . '" name="edd_purchase_download" value="' . esc_attr($args['text']) . '" data-action="edd_add_to_cart" data-download-id="' . esc_attr($download->ID) . '" ' . $data_variable . ' ' . $type . ' ' . $button_display . '/>';
    echo '<a href="' . esc_url(edd_get_checkout_uri()) . '" class="edd_go_to_checkout ' . esc_attr($class) . '" ' . $checkout_display . '>' . __('Checkout', 'easy-digital-downloads') . '</a>';
    ?>

			<?php 
    if (!edd_is_ajax_disabled()) {
        ?>
				<span class="edd-cart-ajax-alert">
					<span class="edd-cart-added-alert" style="display: none;">
						<?php 
        echo '<i class="edd-icon-ok"></i> ' . __('Added to cart', 'easy-digital-downloads');
        ?>
					</span>
				</span>
			<?php 
    }
    ?>
			<?php 
    if (!$download->is_free($args['price_id'])) {
        ?>
				<?php 
        if (edd_display_tax_rate() && edd_prices_include_tax()) {
            echo '<span class="edd_purchase_tax_rate">' . sprintf(__('Includes %1$s&#37; tax', 'easy-digital-downloads'), edd_get_tax_rate() * 100) . '</span>';
        } elseif (edd_display_tax_rate() && !edd_prices_include_tax()) {
            echo '<span class="edd_purchase_tax_rate">' . sprintf(__('Excluding %1$s&#37; tax', 'easy-digital-downloads'), edd_get_tax_rate() * 100) . '</span>';
        }
        ?>
			<?php 
    }
    ?>
		</div><!--end .edd_purchase_submit_wrapper-->

		<input type="hidden" name="download_id" value="<?php 
    echo esc_attr($download->ID);
    ?>
">
		<?php 
    if ($variable_pricing && isset($price_id) && isset($prices[$price_id])) {
        ?>
			<input type="hidden" name="edd_options[price_id][]" id="edd_price_option_<?php 
        echo $download->ID;
        ?>
_1" class="edd_price_option_<?php 
        echo $download->ID;
        ?>
" value="<?php 
        echo $price_id;
        ?>
">
		<?php 
    }
    ?>
		<?php 
    if (!empty($args['direct']) && !$download->is_free($args['price_id'])) {
        ?>
			<input type="hidden" name="edd_action" class="edd_action_input" value="straight_to_gateway">
		<?php 
    } else {
        ?>
			<input type="hidden" name="edd_action" class="edd_action_input" value="add_to_cart">
		<?php 
    }
    ?>

		<?php 
    if (apply_filters('edd_download_redirect_to_checkout', edd_straight_to_checkout(), $download->ID, $args)) {
        ?>
			<input type="hidden" name="edd_redirect_to_checkout" id="edd_redirect_to_checkout" value="1">
		<?php 
    }
    ?>

		<?php 
    do_action('edd_purchase_link_end', $download->ID, $args);
    ?>

	</form><!--end #<?php 
    echo esc_attr($form_id);
    ?>
-->
<?php 
    $purchase_form = ob_get_clean();
    return apply_filters('edd_purchase_download_form', $purchase_form, $args);
}
コード例 #18
0
/**
 * Process cart save
 *
 * @since 1.8
 * @return void
 */
function edd_process_cart_restore($data)
{
    $cart = edd_restore_cart();
    if (!is_wp_error($cart)) {
        wp_redirect(edd_get_checkout_uri());
        exit;
    }
}
コード例 #19
0
</span></th>
                                        <?php 
    do_action('edd_checkout_table_footer_last');
    ?>
                                    </tr>
                                    </tfoot>
                                </table>

                                <table width="100%">
                                    <tr>
                                        <td align="left"><a style="display: inline" href="<?php 
    echo get_home_url();
    ?>
" class="btn btn-dark btn-block ">Tiếp tục mua hàng</a></td>
                                        <td align="right"><a style="display: inline" href="<?php 
    echo edd_get_checkout_uri();
    ?>
" class="btn btn-dark btn-block">Thanh toán</a></td>
                                    </tr>
                                </table>




                            <?php 
}
//resetting the page loop
wp_reset_query();
//resetting the page query
?>
                        </div>
コード例 #20
0
/**
 * Processes a remove discount from cart request
 *
 * @since 1.4.1
 * @return void
 */
function edd_remove_cart_discount()
{
    if (!isset($_GET['discount_id']) || !isset($_GET['discount_code'])) {
        return;
    }
    do_action('edd_pre_remove_cart_discount', absint($_GET['discount_id']));
    edd_unset_cart_discount(urldecode($_GET['discount_code']));
    do_action('edd_post_remove_cart_discount', absint($_GET['discount_id']));
    wp_redirect(edd_get_checkout_uri());
    edd_die();
}
コード例 #21
0
 /**
  * This function adds the WooCommerce or Easy Digital Downloads cart icons/items to the top_nav
  * menu area as the last item.
  */
 function wp_nav_menu_items($items, $args, $ajax = false)
 {
     // Top Navigation area only
     if (isset($ajax) && $ajax || property_exists($args, 'theme_location') && $args->theme_location === 'top_nav') {
         // WooCommerce
         if (class_exists('woocommerce')) {
             $css_class = 'menu-item menu-item-type-cart menu-item-type-woocommerce-cart';
             // Is this the cart page?
             if (is_cart()) {
                 $css_class .= ' current-menu-item';
             }
             $items .= '<li class="' . esc_attr($css_class) . '">';
             $items .= '<a class="cart-contents" href="' . esc_url(WC()->cart->get_cart_url()) . '">';
             $items .= wp_kses_data(WC()->cart->get_cart_total()) . ' - <span class="count">' . wp_kses_data(sprintf(_n('%d item', '%d items', WC()->cart->get_cart_contents_count(), 'simple-shop'), WC()->cart->get_cart_contents_count())) . '</span>';
             $items .= '</a>';
             $items .= '</li>';
         } else {
             if (class_exists('Easy_Digital_Downloads')) {
                 $css_class = 'menu-item menu-item-type-cart menu-item-type-edd-cart';
                 // Is this the cart page?
                 if (edd_is_checkout()) {
                     $css_class .= ' current-menu-item';
                 }
                 $items .= '<li class="' . esc_attr($css_class) . '">';
                 $items .= '<a class="cart-contents" href="' . esc_url(edd_get_checkout_uri()) . '">';
                 $items .= wp_kses_data(edd_cart_subtotal()) . ' - <span class="count">' . wp_kses_data(sprintf(_n('%d item', '%d items', edd_get_cart_quantity(), 'simple-shop'), edd_get_cart_quantity())) . '</span>';
                 $items .= '</a>';
                 $items .= '</li>';
             }
         }
     }
     return $items;
 }
コード例 #22
0
 public function menu_item()
 {
     global $post;
     $menu_item = array('cart_url' => edd_get_checkout_uri(), 'shop_page_url' => get_home_url(), 'cart_contents_count' => edd_get_cart_quantity(), 'cart_total' => edd_currency_filter(edd_format_amount(edd_get_cart_total())));
     return $menu_item;
 }
コード例 #23
0
    /**
     * Display the widget content.
     *
     * @since 1.0
     *
     * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
     * @param array $instance The settings for the particular instance of the widget
     */
    function widget($args, $instance)
    {
        // Merge with defaults
        $instance = wp_parse_args((array) $instance, $this->defaults);
        // Return early if we have no download ID or no variable prices
        if (!isset($instance['download'])) {
            return;
        }
        // Set the download ID
        $download_id = absint($instance['download']);
        // Get the featured price option
        $featured = isset($instance['featured']) && !empty($instance['featured']) ? 'featured' : null;
        // Set the title
        $title = get_the_title($download_id);
        echo $args['before_widget'];
        ?>
		<div itemscope class="pricing-table <?php 
        echo $featured;
        ?>
">
			<div class="pricing-table-top">
				<div class="pricing-table-price">
					<?php 
        edd_price($download_id);
        ?>
				</div>
				<div class="pricing-table-price-desc"><?php 
        echo esc_html($title);
        ?>
</div>
			</div>
			<div class="pricing-table-features">
				<?php 
        checkout_edd_download_details($download_id);
        ?>
				<a class="button" href="<?php 
        echo edd_get_checkout_uri();
        ?>
?edd_action=add_to_cart&amp;download_id=<?php 
        echo absint($download_id);
        ?>
" title="<?php 
        echo esc_attr($title);
        ?>
">
					<?php 
        _e('Buy Now', 'checkout');
        ?>
				</a>
			</div>
		</div>

		<?php 
        echo $args['after_widget'];
    }
コード例 #24
0
ファイル: tickets.php プロジェクト: TakenCdosG/chefs
 *
 * @var bool $must_login
 */
global $edd_options;
$is_there_any_product = false;
$is_there_any_product_to_sell = false;
$stock = Tribe__Tickets_Plus__Commerce__EDD__Main::get_instance()->stock();
ob_start();
?>
<h2 class="tribe-events-tickets-title"><?php 
esc_html_e('Tickets', 'event-tickets-plus');
?>
</h2>

<form action="<?php 
echo esc_url(add_query_arg('eddtickets_process', 1, edd_get_checkout_uri()));
?>
" class="cart" method="post" enctype='multipart/form-data'>
	<table width="100%" class="tribe-events-tickets">
			<?php 
foreach ($tickets as $ticket) {
    $product = edd_get_download($ticket->ID);
    if ($ticket->date_in_range(current_time('timestamp'))) {
        $is_there_any_product = true;
        $data_product_id = 'data-product-id="' . esc_attr($ticket->ID) . '"';
        echo sprintf('<input type="hidden" name="product_id[]"" value="%d">', esc_attr($ticket->ID));
        echo '<tr>';
        echo '<td width="75" class="edd quantity" data-product-id="' . esc_attr($ticket->ID) . '">';
        if ($stock->available_units($product->ID)) {
            // For global stock enabled tickets with a cap, use the cap as the max quantity
            if ($global_stock_enabled && Tribe__Tickets__Global_Stock::CAPPED_STOCK_MODE === $ticket->global_stock_mode()) {
コード例 #25
0
ファイル: template-tags.php プロジェクト: apsolut/theme
/**
 * Returns the URL to upgrade a license from personal -> business or dev, or from business -> dev
 *
 * @since AffiliateWP 1.x
 *
 * @return string
*/
function affwp_get_license_upgrade_url($type = '')
{
    if (!function_exists('edd_get_checkout_uri') || !$type) {
        return home_url('/pricing');
    }
    $args = array('edd_action' => 'upgrade_affwp_license', 'type' => $type);
    return add_query_arg($args, edd_get_checkout_uri());
}
コード例 #26
0
 /**
  * Returns the status label
  * @since 2.7
  * @return string
  */
 function license_status($license_id)
 {
     $status = self::get_license_status($license_id);
     switch ($status) {
         case 'active':
             $status = __('Active', 'edd_sl');
             break;
         case 'inactive':
             $status = __('Inactive', 'edd_sl');
             break;
         case 'expired':
             $status = __('Expired', 'edd_sl');
             if (edd_sl_renewals_allowed()) {
                 $renewal_link = edd_get_checkout_uri(array('edd_license_key' => self::get_license_key($license_id), 'download_id' => self::get_download_id($license_id)));
                 $status .= ', <a href="' . esc_url($renewal_link) . '" title="' . __('Renew this license', 'edd_sl') . '">' . __('renew now', 'edd_sl') . '</a>';
             }
             break;
     }
     return $status;
 }
コード例 #27
0
 /**
  * Grabs the submitted front end tickets form and adds the products to the cart.
  */
 public function process_front_end_tickets_form()
 {
     // We're only interested in EDD Tickets submissions
     if (!isset($_GET['eddtickets_process']) || empty($_POST['product_id'])) {
         return;
     }
     // Add each ticket product to the cart
     foreach ((array) $_POST['product_id'] as $product_id) {
         $quantity = isset($_POST['quantity_' . $product_id]) ? (int) $_POST['quantity_' . $product_id] : 0;
         if ($quantity > 0) {
             $this->add_ticket_to_cart($product_id, $quantity);
         }
     }
     // To minimize accidental re-submissions, redirect back to self
     wp_redirect(edd_get_checkout_uri());
     edd_die();
 }
function idedd_level_links()
{
    $project_id = is_id_project();
    if (!empty($project_id)) {
        $project = new ID_Project($project_id);
        $post_id = $project->get_project_postid();
        $level_count = get_post_meta($post_id, 'ign_product_level_count', true);
        $edd = get_post_meta($post_id, 'idedd_project_pairing', true);
        if (!empty($edd)) {
            $edd_prices = edd_get_variable_prices($edd);
            $checkout_url = edd_get_checkout_uri();
            $start_value = !empty($edd_prices[0]) ? 0 : 1;
            if ($start_value == 0) {
                $level_count = absint($level_count - 1);
            }
            for ($i = $start_value; $i <= $level_count; $i++) {
                $level_id = $start_value == 0 ? absint($i + 1) : $i;
                add_filter('id_level_' . $level_id . '_link', function ($link, $project_id) use($checkout_url, $edd, $i) {
                    // start here
                    $link = $checkout_url . '?edd_action=add_to_cart&download_id=' . $edd . '&edd_options[price_id]=' . $i;
                    return $link;
                }, 1, 2);
            }
        }
    }
}
コード例 #29
0
/**
 * Process the Cart Save
 *
 * @since 1.8
 * @return bool
 */
function edd_save_cart()
{
    if (edd_is_cart_saving_disabled()) {
        return false;
    }
    $user_id = get_current_user_id();
    $cart = EDD()->session->get('edd_cart');
    $token = edd_generate_cart_token();
    $messages = EDD()->session->get('edd_cart_messages');
    if (is_user_logged_in()) {
        update_user_meta($user_id, 'edd_saved_cart', $cart, false);
        update_user_meta($user_id, 'edd_cart_token', $token, false);
    } else {
        $cart = serialize($cart);
        setcookie('edd_saved_cart', $cart, time() + 3600 * 24 * 7, COOKIEPATH, COOKIE_DOMAIN);
        setcookie('edd_cart_token', $token, time() + 3600 * 24 * 7, COOKIEPATH, COOKIE_DOMAIN);
    }
    $messages = EDD()->session->get('edd_cart_messages');
    if (!$messages) {
        $messages = array();
    }
    $messages['edd_cart_save_successful'] = sprintf('<strong>%1$s</strong>: %2$s', __('Success', 'edd'), __('Cart saved successfully. You can restore your cart using this URL:', 'edd') . ' ' . '<a href="' . edd_get_checkout_uri() . '?edd_action=restore_cart&edd_cart_token=' . $token . '">' . edd_get_checkout_uri() . '?edd_action=restore_cart&edd_cart_token=' . $token . '</a>');
    EDD()->session->set('edd_cart_messages', $messages);
    if ($cart) {
        return true;
    }
    return false;
}
コード例 #30
0
 public function get_cart_url()
 {
     global $post;
     $cart_url = edd_get_checkout_uri();
     return $cart_url;
 }