当前位置: 首页>>代码示例>>PHP>>正文


PHP wc_get_checkout_url函数代码示例

本文整理汇总了PHP中wc_get_checkout_url函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_checkout_url函数的具体用法?PHP wc_get_checkout_url怎么用?PHP wc_get_checkout_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wc_get_checkout_url函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_get_checkout_url_ssl

 /**
  * 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);
 }
开发者ID:coderkevin,项目名称:woocommerce,代码行数:15,代码来源:functions.php

示例2: update_cart_action

 /**
  * 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;
         }
     }
 }
开发者ID:johnulist,项目名称:woocommerce,代码行数:84,代码来源:class-wc-form-handler.php

示例3: get_checkout_url

 /**
  * 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();
 }
开发者ID:WPprodigy,项目名称:woocommerce,代码行数:11,代码来源:class-wc-cart.php

示例4: esc_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>
开发者ID:bitoncoin,项目名称:woocommerce,代码行数:30,代码来源:proceed-to-checkout-button.php

示例5: bloginfo

  
$('#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>";
}
开发者ID:willowmagrini,项目名称:dg,代码行数:30,代码来源:custom-login.php

示例6: porto_get_woo_version_number

 * @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');
    ?>
开发者ID:booklein,项目名称:wpbookle,代码行数:30,代码来源:form-checkout.php

示例7: wc_cart_totals_coupon_html

/**
 * 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);
}
开发者ID:coderkevin,项目名称:woocommerce,代码行数:26,代码来源:wc-cart-functions.php

示例8: woocommerce_widget_shopping_cart_proceed_to_checkout

 /**
  * 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>';
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:9,代码来源:wc-template-functions.php

示例9: hocwp_wc_get_checkout_url

function hocwp_wc_get_checkout_url()
{
    return wc_get_checkout_url();
}
开发者ID:skylarkcob,项目名称:hocwp-projects,代码行数:4,代码来源:woocommerce.php

示例10: callback_payapp_status

 /**
  * 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;
 }
开发者ID:EricKim65,项目名称:woosym-korean-localization,代码行数:34,代码来源:class-pg-payapp-main.php

示例11: esc_url

<?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>';
开发者ID:rahul13bhati,项目名称:woocommerce,代码行数:24,代码来源:proceed-to-checkout-button.php

示例12: WC

    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');
开发者ID:booklein,项目名称:wpbookle,代码行数:31,代码来源:mini-cart.php


注:本文中的wc_get_checkout_url函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。