/**
 * 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')));
    }
}
 /**
  * Changes the cross selling HTML to be more in line what we want
  *
  * @param string $html The current HTML, we discard this completely.
  * @param array  $downloads The downloads to cross/up sell.
  *
  * @return string The new HTML.
  */
 public function cross_selling_html($html, $downloads)
 {
     if (edd_is_checkout()) {
         $html = get_template_part('html_includes/shop/checkout-cross-sell', array('return' => true, 'downloads' => $downloads));
     }
     return $html;
 }
Esempio n. 3
0
/**
 * Output the SL JavaScript for the checkout page
 *
 * @since  3.2
 * @return void
 */
function edd_sl_checkout_js()
{
    if (!function_exists('edd_is_checkout')) {
        return;
    }
    if (!edd_is_checkout()) {
        return;
    }
    ?>
	<script>
	jQuery(document).ready(function($) {
		$('#edd_sl_show_renewal_form, #edd-cancel-license-renewal').click(function(e) {
			e.preventDefault();
			$('#edd-license-key-container-wrap,#edd_sl_show_renewal_form,.edd-sl-renewal-actions').toggle();
			$('#edd-license-key').focus();
		});

		$('#edd-license-key').keyup(function(e) {
			var input  = $('#edd-license-key');
			var button = $('#edd-add-license-renewal');

			if ( input.val() != '' ) {
				button.prop("disabled", false);
			} else {
				button.prop("disabled", true);
			}
		});
	});
	</script>
<?php 
}
/**
 * Process the Add to Cart request
 *
 * @since 1.0
 *
 * @param $data
 */
function edd_process_add_to_cart($data)
{
    $download_id = absint($data['download_id']);
    $options = isset($data['edd_options']) ? $data['edd_options'] : array();
    if (!empty($data['edd_download_quantity'])) {
        $options['quantity'] = absint($data['edd_download_quantity']);
    }
    if (isset($options['price_id']) && is_array($options['price_id'])) {
        foreach ($options['price_id'] as $key => $price_id) {
            $options['quantity'][$key] = isset($data['edd_download_quantity_' . $price_id]) ? absint($data['edd_download_quantity_' . $price_id]) : 1;
        }
    }
    $cart = edd_add_to_cart($download_id, $options);
    if (edd_straight_to_checkout() && !edd_is_checkout()) {
        $query_args = remove_query_arg(array('edd_action', 'download_id', 'edd_options'));
        $query_part = strpos($query_args, "?");
        $url_parameters = '';
        if (false !== $query_part) {
            $url_parameters = substr($query_args, $query_part);
        }
        wp_redirect(edd_get_checkout_uri() . $url_parameters, 303);
        edd_die();
    } else {
        wp_redirect(remove_query_arg(array('edd_action', 'download_id', 'edd_options')));
        edd_die();
    }
}
Esempio n. 5
0
 function checkout_no_sidebars()
 {
     if (edd_is_checkout()) {
         // TODO: force fluid layout
         add_filter('maera/sidebar/primary', '__return_false');
         add_filter('maera/sidebar/secondary', '__return_false');
     }
 }
function edd_rp_display_checkout()
{
    if (edd_is_checkout()) {
        // GitHub Issue: https://github.com/pippinsplugins/Easy-Digital-Downloads/issues/1059
        add_filter('edd_straight_to_checkout', '__return_true');
    }
    edd_rp_get_template_part('checkout_recommendations');
}
/**
 * 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();
    }
}
Esempio n. 8
0
function edd_rp_display_checkout()
{
    global $post;
    if (edd_is_checkout()) {
        // GitHub Issue: https://github.com/pippinsplugins/Easy-Digital-Downloads/issues/1059
        add_filter('edd_straight_to_checkout', '__return_true');
    }
    EDD()->session->set('edd_has_recommendations', $post->ID);
    edd_rp_get_template_part('checkout_recommendations');
}
function pw_edd_disable_gateway_on_checkout($gateways)
{
    if (edd_is_checkout()) {
        // Disable Stripe if the download with an ID of 10 is in the cart
        if (edd_item_in_cart(10)) {
            unset($gateways['stripe']);
        }
    }
    return $gateways;
}
Esempio n. 10
0
/**
 * Process the Add to Cart request
 *
 * @since 1.0
 *
 * @param $data
 */
function edd_process_add_to_cart( $data ) {
	$download_id = absint( $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();
	} else {
		wp_redirect( remove_query_arg( array( 'edd_action', 'download_id', 'edd_options' ) ) ); edd_die();
	}
}
Esempio n. 11
0
/**
 * A helper function to determine whether the current post should have the meta displayed.
 *
 * @param   WP_Post $post Optional. If a post is not passed, the current $post object will be used.
 * @return  boolean
 * @since   1.0.0
 */
function reach_hide_post_meta($post = '')
{
    if (!strlen($post)) {
        global $post;
    }
    if (reach_has_edd() && edd_is_checkout()) {
        return true;
    }
    if (function_exists('hide_meta_start')) {
        return get_post_meta($post->ID, '_hide_meta', true);
    } else {
        return get_post_meta($post->ID, '_reach_hide_post_meta', true);
    }
}
Esempio n. 12
0
/**
 * Navigation extras
 *
 * @since 1.0
*/
function pp_load_navigation_extras()
{
    // don't load on checkout
    if (function_exists('edd_is_checkout') && edd_is_checkout()) {
        return;
    }
    if (function_exists('pp_share_icon')) {
        pp_share_icon();
    }
    if (function_exists('pp_show_cart_quantity_icon')) {
        pp_show_cart_quantity_icon();
    }
    get_search_form();
}
Esempio n. 13
0
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     if (!empty($instance['hide_on_checkout']) && edd_is_checkout()) {
         return;
     }
     $args['id'] = isset($args['id']) ? $args['id'] : 'edd_cart_widget';
     $instance['title'] = isset($instance['title']) ? $instance['title'] : '';
     $title = apply_filters('widget_title', $instance['title'], $instance, $args['id']);
     echo $args['before_widget'];
     if ($title) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     do_action('edd_before_cart_widget');
     edd_shopping_cart(true);
     do_action('edd_after_cart_widget');
     echo $args['after_widget'];
 }
Esempio n. 14
0
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     if (isset($instance['hide_on_checkout']) && edd_is_checkout()) {
         return;
     }
     if (!isset($args['id'])) {
         $args['id'] = 'edd_cart_widget';
     }
     $title = apply_filters('widget_title', $instance['title'], $instance, $args['id']);
     global $post, $edd_options;
     echo $args['before_widget'];
     if ($title) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     do_action('edd_before_cart_widget');
     edd_shopping_cart(true);
     do_action('edd_after_cart_widget');
     echo $args['after_widget'];
 }
Esempio n. 15
0
/**
 * Process the Add to Cart request
 *
 * @since 1.0
 *
 * @param $data
 */
function edd_process_add_to_cart($data)
{
    $download_id = absint($data['download_id']);
    $options = isset($data['edd_options']) ? $data['edd_options'] : array();
    if (!empty($data['edd_download_quantity'])) {
        $options['quantity'] = absint($data['edd_download_quantity']);
    }
    if (is_array($options['price_id'])) {
        foreach ($options['price_id'] as $key => $price_id) {
            $options['quantity'][$key] = absint($data['edd_download_quantity_' . $price_id]);
        }
    }
    $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();
    } else {
        wp_redirect(remove_query_arg(array('edd_action', 'download_id', 'edd_options')));
        edd_die();
    }
}
Esempio n. 16
0
/**
 * Terms and conditions
 */
function affwp_show_refund_policy()
{
    if (!function_exists('edd_is_checkout') || !edd_is_checkout()) {
        return;
    }
    $post = get_page_by_title('refund policy');
    ?>

	<div id="refund-policy" class="popup entry-content mfp-with-anim mfp-hide">
		<h1><?php 
    echo $post->post_title;
    ?>
</h1>
		<?php 
    echo wpautop($post->post_content, true);
    ?>
	</div>

	<script type="text/javascript">
			jQuery(document).ready(function() {
				jQuery("#load-refund-policy").fancybox({
					type: 'inline',
					padding: 32,
					maxWidth: 720,
					helpers: {
					    overlay: {
					      locked: false
					    }
					  },
					 openEffect	: 'fade',
					 closeEffect	: 'fade'
				});
			});
		</script>

	<?php 
}
/**
 * Load Scripts
 *
 * Enqueues the required scripts.
 *
 * @since 1.0
 * @global $edd_options
 * @global $post
 * @return void
 */
function edd_load_scripts()
{
    global $edd_options, $post;
    $js_dir = EDD_PLUGIN_URL . 'assets/js/';
    wp_enqueue_script('jquery');
    // 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_enqueue_script('creditCardValidator', $js_dir . 'jquery.creditCardValidator' . $suffix . '.js', array('jquery'), EDD_VERSION);
        }
        wp_enqueue_script('edd-checkout-global', $js_dir . 'edd-checkout-global' . $suffix . '.js', array('jquery'), EDD_VERSION);
        wp_localize_script('edd-checkout-global', 'edd_global_vars', array('ajaxurl' => edd_get_ajax_url(), 'checkout_nonce' => wp_create_nonce('edd_checkout_nonce'), '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'), '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'), 'purchase_loading' => __('Please Wait...', 'edd'), 'complete_purchasse' => __('Purchase', 'edd')));
    }
    // Load AJAX scripts, if enabled
    if (edd_is_ajax_enabled()) {
        wp_enqueue_script('edd-ajax', $js_dir . 'edd-ajax' . $suffix . '.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'), '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' => EDD_PLUGIN_URL . 'assets/images/loading.gif', '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'));
    }
}
/**
 * Adds body classes for EDD pages
 *
 * @since 2.1
 * @param array $class current classes
 * @return array Modified array of classes
 */
function edd_add_body_classes($class)
{
    $classes = (array) $class;
    if (edd_is_checkout()) {
        $classes[] = 'edd-checkout';
        $classes[] = 'edd-page';
    }
    if (edd_is_success_page()) {
        $classes[] = 'edd-success';
        $classes[] = 'edd-page';
    }
    if (edd_is_failed_transaction_page()) {
        $classes[] = 'edd-failed-transaction';
        $classes[] = 'edd-page';
    }
    if (edd_is_purchase_history_page()) {
        $classes[] = 'edd-purchase-history';
        $classes[] = 'edd-page';
    }
    if (edd_is_test_mode()) {
        $classes[] = 'edd-test-mode';
        $classes[] = 'edd-page';
    }
    return array_unique($classes);
}
 /**
  * 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;
 }
    /**
     * Print client ID in header
     *
     * @access public
     * @since  2.4
     * @return void
     */
    public function print_client()
    {
        if (!edd_is_checkout()) {
            return;
        }
        ?>
		<script>
			window.onAmazonLoginReady = function() {
				amazon.Login.setClientId(<?php 
        echo json_encode(edd_get_option('amazon_client_id', ''));
        ?>
);
			};
		</script>
		<?php 
    }
/**
 * Disable the WooCommerce 'Un-force SSL when leaving checkout' option on EDD checkout
 * to prevent redirect loops
 *
 * @since 2.1
 * @return void
 */
function edd_disable_woo_ssl_on_checkout()
{
    if (edd_is_checkout() && edd_is_ssl_enforced()) {
        remove_action('template_redirect', array('WC_HTTPS', 'unforce_https_template_redirect'));
    }
}
/**
 * Adds the 'nocache' parameter to the provided URL
 *
 * @since  2.4.4
 * @param  string $url The URL being requested
 * @return string      The URL with cache busting added or not
 */
function edd_add_cache_busting($url = '')
{
    $no_cache_checkout = edd_get_option('no_cache_checkout', false);
    if (edd_is_caching_plugin_active() || edd_is_checkout() && $no_cache_checkout) {
        $url = add_query_arg('nocache', 'true', $url);
    }
    return $url;
}
Esempio n. 23
0
/**
 * Register Styles
 *
 * Checks the styles option and hooks the required filter.
 *
 * @since 1.0
 * @return void
 */
function edd_register_styles()
{
    if (edd_get_option('disable_styles', false)) {
        return;
    }
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    $file = 'edd' . $suffix . '.css';
    $templates_dir = edd_get_theme_template_dir_name();
    $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()) . $templates_dir . $file;
    $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()) . $templates_dir . 'edd.css';
    $parent_theme_style_sheet = trailingslashit(get_template_directory()) . $templates_dir . $file;
    $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()) . $templates_dir . 'edd.css';
    $edd_plugin_style_sheet = trailingslashit(edd_get_templates_dir()) . $file;
    // Look in the child theme directory first, followed by the parent theme, followed by the EDD core templates directory
    // Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled.
    // This allows users to copy just edd.css to their theme
    if (file_exists($child_theme_style_sheet) || !empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2))) {
        if (!empty($nonmin)) {
            $url = trailingslashit(get_stylesheet_directory_uri()) . $templates_dir . 'edd.css';
        } else {
            $url = trailingslashit(get_stylesheet_directory_uri()) . $templates_dir . $file;
        }
    } elseif (file_exists($parent_theme_style_sheet) || !empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2))) {
        if (!empty($nonmin)) {
            $url = trailingslashit(get_template_directory_uri()) . $templates_dir . 'edd.css';
        } else {
            $url = trailingslashit(get_template_directory_uri()) . $templates_dir . $file;
        }
    } elseif (file_exists($edd_plugin_style_sheet) || file_exists($edd_plugin_style_sheet)) {
        $url = trailingslashit(edd_get_templates_url()) . $file;
    }
    wp_register_style('edd-styles', $url, array(), EDD_VERSION, 'all');
    wp_enqueue_style('edd-styles');
    if (edd_is_checkout() && is_ssl()) {
        // Dashicons are used to show the padlock icon on the credit card form
        wp_enqueue_style('dashicons');
    }
}
Esempio n. 24
0
/**
 * Handle rewriting asset URLs for SSL enforced checkouts
 *
 * @since 2.0
 * @return void
 */
function edd_enforced_ssl_asset_handler()
{
    if (!edd_is_ssl_enforced() || !edd_is_checkout() || is_admin()) {
        return;
    }
    $filters = array('post_thumbnail_html', 'wp_get_attachment_url', 'wp_get_attachment_image_attributes', 'wp_get_attachment_url', 'option_stylesheet_url', 'option_template_url', 'script_loader_src', 'style_loader_src', 'template_directory_uri', 'stylesheet_directory_uri', 'site_url');
    $filters = apply_filters('edd_enforced_ssl_asset_filters', $filters);
    foreach ($filters as $filter) {
        add_filter($filter, 'edd_enforced_ssl_asset_filter', 1);
    }
}
Esempio n. 25
0
 /**
  * Enqueues all theme assets
  */
 public function enqueue_assets()
 {
     wp_enqueue_style('yoast-com');
     wp_enqueue_script('yoast-com');
     wp_localize_script('yoast-com', 'YoastAjax', array('ajaxurl' => admin_url('admin-ajax.php')));
     if (function_exists('edd_is_checkout') && edd_is_checkout()) {
         wp_enqueue_style('chosen');
         wp_enqueue_script('yoast-com-checkout');
         wp_localize_script('yoast-com-checkout', 'yoast_com_checkout_vars', array('ajaxurl' => edd_get_ajax_url(), 'checkout_nonce' => wp_create_nonce('edd_checkout_nonce'), 'taxes_enabled' => edd_use_taxes() ? '1' : '0', 'tax_rates' => $this->get_tax_rates()));
     }
     // Remove the cross selling CSS because we overwrite it completely.
     wp_deregister_style('edd-csau-css');
     if (is_singular('post') && !Hide_Comments::hide_comments() && comments_open()) {
         wp_enqueue_script('comment-reply');
     }
     if (is_singular(array('course', 'lesson', 'llms_quiz'))) {
         wp_enqueue_script('yoast-com-academy');
     }
 }
/**
 * Disables opengraph tags on the checkout page
 *
 * There is a bizarre conflict that makes the checkout errors not get displayed
 * when the Jetpack opengraph tags are displayed
 *
 * @access      private
 * @since       1.3.3.1
 * @return      bool
*/
function edd_disable_jetpack_og_on_checkout()
{
    if (edd_is_checkout()) {
        remove_action('wp_head', 'jetpack_og_tags');
    }
}
/**
 * Renders the Discount Code field which allows users to enter a discount code.
 * This field is only displayed if there are any active discounts on the site else
 * it's not displayed.
 *
 * @since 1.2.2
 * @return void
*/
function edd_discount_field()
{
    if (isset($_GET['payment-mode']) && edd_is_ajax_disabled()) {
        return;
        // Only show before a payment method has been selected if ajax is disabled
    }
    if (!edd_is_checkout()) {
        return;
    }
    if (edd_has_active_discounts() && edd_get_cart_total()) {
        $color = edd_get_option('checkout_color', 'blue');
        $color = $color == 'inherit' ? '' : $color;
        $style = edd_get_option('button_style', 'button');
        ?>
		<fieldset id="edd_discount_code">
			<p id="edd_show_discount" style="display:none;">
				<?php 
        _e('Have a discount code?', 'edd');
        ?>
 <a href="#" class="edd_discount_link"><?php 
        echo _x('Click to enter it', 'Entering a discount code', 'edd');
        ?>
</a>
			</p>
			<p id="edd-discount-code-wrap" class="edd-cart-adjustment">
				<label class="edd-label" for="edd-discount">
					<?php 
        _e('Discount', 'edd');
        ?>
					<img src="<?php 
        echo EDD_PLUGIN_URL;
        ?>
assets/images/loading.gif" id="edd-discount-loader" style="display:none;"/>
				</label>
				<span class="edd-description"><?php 
        _e('Enter a coupon code if you have one.', 'edd');
        ?>
</span>
				<input class="edd-input" type="text" id="edd-discount" name="edd-discount" placeholder="<?php 
        _e('Enter discount', 'edd');
        ?>
"/>
				<input type="submit" class="edd-apply-discount edd-submit button <?php 
        echo $color . ' ' . $style;
        ?>
" value="<?php 
        echo _x('Apply', 'Apply discount at checkout', 'edd');
        ?>
"/>
				<span id="edd-discount-error-wrap" class="edd_error edd-alert edd-alert-error" style="display:none;"></span>
			</p>
		</fieldset>
<?php 
    }
}
Esempio n. 28
0
/**
 * Skin the select menus after the ajax call for the payment method has run
 * Can't think of a better way to do this
 */
function pp_edd_checkout_js()
{
    if (!(function_exists('edd_is_checkout') && edd_is_checkout() || is_page('contact'))) {
        return;
    }
    ?>
	<script>
		jQuery(document).ready(function($) {
			 $(".edd-select").chosen({disable_search_threshold: 15});
		});
			
		jQuery( document ).ajaxComplete(function( event,request, settings ) {
			jQuery(".edd-select").chosen({disable_search_threshold: 15});
		});
	</script>
	<?php 
}
/**
 * Add fee at EDD checkout
 *
 * @since 1.0
 */
function ninja_forms_edd_add_fee()
{
    // make sure we're on EDD checkout
    if (!edd_is_checkout()) {
        return;
    }
    $amount = EDD()->session->get('ninja_forms_total');
    $label = EDD()->session->get('ninja_forms_fee_label');
    // there's an amount and label, add our fee
    if ($amount) {
        EDD()->fees->add_fee(array('amount' => $amount, 'label' => $label, 'id' => 'ninja_forms_edd_fee', 'type' => 'item'));
    }
    // remove fee from session
    EDD()->session->set('ninja_forms_total', '');
    // remove fee label from session
    EDD()->session->set('ninja_forms_fee_label', '');
}
Esempio n. 30
0
/**
 * Load our javascript
 *
 * @access      public
 * @since       1.0
 * @return      void
 */
function edd_stripe_js($override = false)
{
    if (function_exists('edd_is_checkout')) {
        global $edd_options;
        if (isset($edd_options['stripe_js_fallback'])) {
            return;
        }
        // in fallback mode
        $publishable_key = NULL;
        if (edd_is_test_mode()) {
            $publishable_key = trim($edd_options['test_publishable_key']);
        } else {
            $publishable_key = trim($edd_options['live_publishable_key']);
        }
        if ((edd_is_checkout() || $override) && edd_is_gateway_active('stripe')) {
            wp_enqueue_script('stripe-js', 'https://js.stripe.com/v2/', array('jquery'));
            wp_enqueue_script('edd-stripe-js', EDDSTRIPE_PLUGIN_URL . 'edd-stripe.js', array('jquery', 'stripe-js'), EDD_STRIPE_VERSION);
            $stripe_vars = array('publishable_key' => $publishable_key, 'is_ajaxed' => edd_is_ajax_enabled() ? 'true' : 'false');
            wp_localize_script('edd-stripe-js', 'edd_stripe_vars', $stripe_vars);
        }
    }
}