Example #1
0
 /**
  * Test get_checkout_url over HTTP.
  *
  * @since 2.5.0
  */
 public function test_get_checkout_url_ssl()
 {
     // Get the original setting
     $o_setting = get_option('woocommerce_force_ssl_checkout');
     // Force SSL checkout
     update_option('woocommerce_force_ssl_checkout', 'yes');
     $this->assertEquals($this->get_checkout_url(), wc_get_checkout_url());
     // Restore option
     update_option('woocommerce_force_ssl_checkout', $o_setting);
 }
 /**
  * Remove from cart/update.
  */
 public static function update_cart_action()
 {
     if (!empty($_POST['apply_coupon']) && !empty($_POST['coupon_code'])) {
         // Add Discount
         WC()->cart->add_discount(sanitize_text_field($_POST['coupon_code']));
     } elseif (isset($_GET['remove_coupon'])) {
         // Remove Coupon Codes
         WC()->cart->remove_coupon(wc_clean($_GET['remove_coupon']));
     } elseif (!empty($_GET['remove_item']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'woocommerce-cart')) {
         // Remove from cart
         $cart_item_key = sanitize_text_field($_GET['remove_item']);
         if ($cart_item = WC()->cart->get_cart_item($cart_item_key)) {
             WC()->cart->remove_cart_item($cart_item_key);
             $product = wc_get_product($cart_item['product_id']);
             $item_removed_title = apply_filters('woocommerce_cart_item_removed_title', $product ? sprintf(_x('“%s”', 'Item name in quotes', 'woocommerce'), $product->get_title()) : __('Item', 'woocommerce'), $cart_item);
             // Don't show undo link if removed item is out of stock.
             if ($product->is_in_stock() && $product->has_enough_stock($cart_item['quantity'])) {
                 $removed_notice = sprintf(__('%s removed.', 'woocommerce'), $item_removed_title);
                 $removed_notice .= ' <a href="' . esc_url(WC()->cart->get_undo_url($cart_item_key)) . '">' . __('Undo?', 'woocommerce') . '</a>';
             } else {
                 $removed_notice = sprintf(__('%s removed.', 'woocommerce'), $item_removed_title);
             }
             wc_add_notice($removed_notice);
         }
         $referer = wp_get_referer() ? remove_query_arg(array('remove_item', 'add-to-cart', 'added-to-cart'), add_query_arg('removed_item', '1', wp_get_referer())) : wc_get_cart_url();
         wp_safe_redirect($referer);
         exit;
     } elseif (!empty($_GET['undo_item']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'woocommerce-cart')) {
         // Undo Cart Item
         $cart_item_key = sanitize_text_field($_GET['undo_item']);
         WC()->cart->restore_cart_item($cart_item_key);
         $referer = wp_get_referer() ? remove_query_arg(array('undo_item', '_wpnonce'), wp_get_referer()) : wc_get_cart_url();
         wp_safe_redirect($referer);
         exit;
     }
     // Update Cart - checks apply_coupon too because they are in the same form
     if ((!empty($_POST['apply_coupon']) || !empty($_POST['update_cart']) || !empty($_POST['proceed'])) && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-cart')) {
         $cart_updated = false;
         $cart_totals = isset($_POST['cart']) ? $_POST['cart'] : '';
         if (!WC()->cart->is_empty() && is_array($cart_totals)) {
             foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
                 $_product = $values['data'];
                 // Skip product if no updated quantity was posted
                 if (!isset($cart_totals[$cart_item_key]) || !isset($cart_totals[$cart_item_key]['qty'])) {
                     continue;
                 }
                 // Sanitize
                 $quantity = apply_filters('woocommerce_stock_amount_cart_item', wc_stock_amount(preg_replace("/[^0-9\\.]/", '', $cart_totals[$cart_item_key]['qty'])), $cart_item_key);
                 if ('' === $quantity || $quantity == $values['quantity']) {
                     continue;
                 }
                 // Update cart validation
                 $passed_validation = apply_filters('woocommerce_update_cart_validation', true, $cart_item_key, $values, $quantity);
                 // is_sold_individually
                 if ($_product->is_sold_individually() && $quantity > 1) {
                     wc_add_notice(sprintf(__('You can only have 1 %s in your cart.', 'woocommerce'), $_product->get_title()), 'error');
                     $passed_validation = false;
                 }
                 if ($passed_validation) {
                     WC()->cart->set_quantity($cart_item_key, $quantity, false);
                     $cart_updated = true;
                 }
             }
         }
         // Trigger action - let 3rd parties update the cart if they need to and update the $cart_updated variable
         $cart_updated = apply_filters('woocommerce_update_cart_action_cart_updated', $cart_updated);
         if ($cart_updated) {
             // Recalc our totals
             WC()->cart->calculate_totals();
         }
         if (!empty($_POST['proceed'])) {
             wp_safe_redirect(wc_get_checkout_url());
             exit;
         } elseif ($cart_updated) {
             wc_add_notice(__('Cart updated.', 'woocommerce'));
             $referer = remove_query_arg('remove_coupon', wp_get_referer() ? wp_get_referer() : wc_get_cart_url());
             wp_safe_redirect($referer);
             exit;
         }
     }
 }
Example #3
0
 /**
  * Gets the url to the checkout page.
  *
  * @deprecated 2.5.0 in favor to wc_get_checkout_url()
  *
  * @return string url to page
  */
 public function get_checkout_url()
 {
     return wc_get_checkout_url();
 }
 * Proceed to checkout button
 *
 * Contains the markup for the proceed to checkout button on the cart.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/cart/proceed-to-checkout-button.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
 * will need to copy the new files to your theme to maintain compatibility. We try to do this.
 * as little as possible, but it does happen. When this occurs the version of the template file will.
 * be bumped and the readme will list any important changes.
 *
 * @see     http://docs.woothemes.com/document/template-structure/
 * @author  WooThemes
 * @package WooCommerce/Templates
 * @version 2.4.0
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
?>

<a href="<?php 
echo esc_url(wc_get_checkout_url());
?>
" class="checkout-button button alt wc-forward">
	<?php 
echo __('Proceed to Checkout', 'woocommerce');
?>
</a>
Example #5
0
  
$('#result').html('<img src="<?php 
        bloginfo('template_url');
        ?>
/images/loader.gif" class="loader" />').fadeIn();  
var input_data = $('#wp_login_form').serialize();  
$.ajax({  
type: "POST",  
url:  "<?php 
        echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        ?>
",  
data: input_data,  
success: function(msg){  
$('.loader').remove();  
$('<div>').html(msg).appendTo('div#result').hide().fadeIn('slow');  
}  
});  
return false;  
  
});  
</script>  
  
</div>  
</div>  
<?php 
        get_footer();
    }
} else {
    echo "<script type='text/javascript'>window.location='" . esc_url(wc_get_checkout_url()) . "'</script>";
}
Example #6
0
 * @package 	WooCommerce/Templates
 * @version     2.3.0
 */
if (!defined('ABSPATH')) {
    exit;
}
$porto_woo_version = porto_get_woo_version_number();
wc_print_notices();
do_action('woocommerce_before_checkout_form', $checkout);
// If checkout registration is disabled and not logged in, the user cannot checkout
if (!$checkout->enable_signup && !$checkout->enable_guest_checkout && !is_user_logged_in()) {
    echo apply_filters('woocommerce_checkout_must_be_logged_in_message', __('You must be logged in to checkout.', 'woocommerce'));
    return;
}
// filter hook for include new pages inside the payment method
$get_checkout_url = version_compare($porto_woo_version, '2.5', '<') ? apply_filters('woocommerce_get_checkout_url', WC()->cart->get_checkout_url()) : wc_get_checkout_url();
?>

<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php 
echo esc_url($get_checkout_url);
?>
" enctype="multipart/form-data">

	<?php 
if (sizeof($checkout->checkout_fields) > 0) {
    ?>

		<?php 
    do_action('woocommerce_checkout_before_customer_details');
    ?>
/**
 * Get a coupon value.
 *
 * @access public
 * @param string $coupon
 */
function wc_cart_totals_coupon_html($coupon)
{
    if (is_string($coupon)) {
        $coupon = new WC_Coupon($coupon);
    }
    $value = array();
    if ($amount = WC()->cart->get_coupon_discount_amount($coupon->code, WC()->cart->display_cart_ex_tax)) {
        $discount_html = '-' . wc_price($amount);
    } else {
        $discount_html = '';
    }
    $value[] = apply_filters('woocommerce_coupon_discount_amount_html', $discount_html, $coupon);
    if ($coupon->enable_free_shipping()) {
        $value[] = __('Free shipping coupon', 'woocommerce');
    }
    // get rid of empty array elements
    $value = array_filter($value);
    $value = implode(', ', $value) . ' <a href="' . esc_url(add_query_arg('remove_coupon', urlencode($coupon->code), defined('WOOCOMMERCE_CHECKOUT') ? wc_get_checkout_url() : wc_get_cart_url())) . '" class="woocommerce-remove-coupon" data-coupon="' . esc_attr($coupon->code) . '">' . __('[Remove]', 'woocommerce') . '</a>';
    echo apply_filters('woocommerce_cart_totals_coupon_html', $value, $coupon);
}
 /**
  * Output the proceed to checkout button.
  *
  * @subpackage	Cart
  */
 function woocommerce_widget_shopping_cart_proceed_to_checkout()
 {
     echo '<a href="' . esc_url(wc_get_checkout_url()) . '" class="button checkout wc-forward">' . __('Checkout', 'woocommerce') . '</a>';
 }
function hocwp_wc_get_checkout_url()
{
    return wc_get_checkout_url();
}
 /**
  * AJAX 콜백. order key 에 대응해서 해당 order 의 주문 상태를 반환한다.
  *
  * 요구하는 파라미터: $_GET['order_key']
  * JSON 응답:
  *  success:      bool
  *  message:      string  success or 에러 메시지
  *  redirect:     string  리다이렉트 주소
  *  order_id:     int     success=true 이면 order id
  *  order_status: string  success=true 이면 order status 문자열.
  *  (pending|processing|completed)
  *
  * @action wc_ajax_{wskl-payapp-status}
  */
 public static function callback_payapp_status()
 {
     if (!defined('DOING_AJAX') || !defined('WC_DOING_AJAX')) {
         die(-1);
     }
     $order_key = isset($_GET['order_key']) ? sanitize_text_field($_GET['order_key']) : 0;
     $order = wc_get_order(wc_get_order_id_by_order_key($order_key));
     if (!$order) {
         wc_add_notice(__('주문 과정에 문제가 발생했습니다. 다시 시도해 주세요.', 'wskl'), 'error');
         wp_send_json(array('success' => FALSE, 'message' => 'An invalid order key received.', 'redirect' => wc_get_checkout_url()));
         die;
     }
     if ($order->has_status(array('processing', 'completed'))) {
         $redirect = $order->get_checkout_order_received_url();
     } else {
         $redirect = '';
     }
     wp_send_json(array('success' => TRUE, 'message' => 'success', 'order_id' => $order->id, 'order_status' => $order->get_status(), 'redirect' => $redirect));
     die;
 }
<?php

/**
 * Proceed to checkout button
 *
 * Contains the markup for the proceed to checkout button on the cart.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/cart/proceed-to-checkout-button.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
 * will need to copy the new files to your theme to maintain compatibility. We try to do this.
 * as little as possible, but it does happen. When this occurs the version of the template file will.
 * be bumped and the readme will list any important changes.
 *
 * @see     http://docs.woothemes.com/document/template-structure/
 * @author  WooThemes
 * @package WooCommerce/Templates
 * @version 2.4.0
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
echo '<a href="' . esc_url(wc_get_checkout_url()) . '" class="checkout-button button alt wc-forward">' . __('Proceed to Checkout', 'woocommerce') . '</a>';
Example #12
0
    echo WC()->cart->get_cart_subtotal();
    ?>
</p>

	<?php 
    do_action('woocommerce_widget_shopping_cart_before_buttons');
    ?>

	<p class="buttons">
		<a href="<?php 
    echo esc_url(version_compare($porto_woo_version, '2.5', '<') ? WC()->cart->get_cart_url() : wc_get_cart_url());
    ?>
" class="button wc-forward"><?php 
    _e('View Cart', 'woocommerce');
    ?>
</a>
		<a href="<?php 
    echo esc_url(version_compare($porto_woo_version, '2.5', '<') ? WC()->cart->get_checkout_url() : wc_get_checkout_url());
    ?>
" class="button checkout wc-forward"><?php 
    _e('Checkout', 'woocommerce');
    ?>
</a>
	</p>

<?php 
}
?>

<?php 
do_action('woocommerce_after_mini_cart');