本文整理汇总了PHP中woocommerce_checkout_payment函数的典型用法代码示例。如果您正苦于以下问题:PHP woocommerce_checkout_payment函数的具体用法?PHP woocommerce_checkout_payment怎么用?PHP woocommerce_checkout_payment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了woocommerce_checkout_payment函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_action
<?php
do_action('woocommerce_checkout_order_review');
?>
</div>
<?php
do_action('woocommerce_checkout_after_order_review');
?>
</div>
<div class="col-2">
<?php
do_action('woocommerce_checkout_shipping');
?>
<?php
woocommerce_checkout_payment();
?>
</div>
</div>
<?php
do_action('woocommerce_checkout_after_customer_details');
?>
<?php
}
?>
</form>
<?php
示例2: update_order_review
/**
* AJAX update order review on checkout
*/
public static function update_order_review()
{
ob_start();
check_ajax_referer('update-order-review', 'security');
if (!defined('WOOCOMMERCE_CHECKOUT')) {
define('WOOCOMMERCE_CHECKOUT', true);
}
if (WC()->cart->is_empty()) {
$data = array('fragments' => apply_filters('woocommerce_update_order_review_fragments', array('form.woocommerce-checkout' => '<div class="woocommerce-error">' . __('Sorry, your session has expired.', 'woocommerce') . ' <a href="' . home_url() . '" class="wc-backward">' . __('Return to homepage', 'woocommerce') . '</a></div>')));
wp_send_json($data);
die;
}
do_action('woocommerce_checkout_update_order_review', $_POST['post_data']);
$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
if (isset($_POST['shipping_method']) && is_array($_POST['shipping_method'])) {
foreach ($_POST['shipping_method'] as $i => $value) {
$chosen_shipping_methods[$i] = wc_clean($value);
}
}
WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
WC()->session->set('chosen_payment_method', empty($_POST['payment_method']) ? '' : $_POST['payment_method']);
if (isset($_POST['country'])) {
WC()->customer->set_country($_POST['country']);
}
if (isset($_POST['state'])) {
WC()->customer->set_state($_POST['state']);
}
if (isset($_POST['postcode'])) {
WC()->customer->set_postcode($_POST['postcode']);
}
if (isset($_POST['city'])) {
WC()->customer->set_city($_POST['city']);
}
if (isset($_POST['address'])) {
WC()->customer->set_address($_POST['address']);
}
if (isset($_POST['address_2'])) {
WC()->customer->set_address_2($_POST['address_2']);
}
if (wc_ship_to_billing_address_only()) {
if (isset($_POST['country'])) {
WC()->customer->set_shipping_country($_POST['country']);
}
if (isset($_POST['state'])) {
WC()->customer->set_shipping_state($_POST['state']);
}
if (isset($_POST['postcode'])) {
WC()->customer->set_shipping_postcode($_POST['postcode']);
}
if (isset($_POST['city'])) {
WC()->customer->set_shipping_city($_POST['city']);
}
if (isset($_POST['address'])) {
WC()->customer->set_shipping_address($_POST['address']);
}
if (isset($_POST['address_2'])) {
WC()->customer->set_shipping_address_2($_POST['address_2']);
}
} else {
if (isset($_POST['s_country'])) {
WC()->customer->set_shipping_country($_POST['s_country']);
}
if (isset($_POST['s_state'])) {
WC()->customer->set_shipping_state($_POST['s_state']);
}
if (isset($_POST['s_postcode'])) {
WC()->customer->set_shipping_postcode($_POST['s_postcode']);
}
if (isset($_POST['s_city'])) {
WC()->customer->set_shipping_city($_POST['s_city']);
}
if (isset($_POST['s_address'])) {
WC()->customer->set_shipping_address($_POST['s_address']);
}
if (isset($_POST['s_address_2'])) {
WC()->customer->set_shipping_address_2($_POST['s_address_2']);
}
}
WC()->cart->calculate_totals();
// Get order review fragment
ob_start();
woocommerce_order_review();
$woocommerce_order_review = ob_get_clean();
// Get checkout payment fragment
ob_start();
woocommerce_checkout_payment();
$woocommerce_checkout_payment = ob_get_clean();
// Get messages if reload checkout is not true
$messages = '';
if (!isset(WC()->session->reload_checkout)) {
ob_start();
wc_print_notices();
$messages = ob_get_clean();
}
$data = array('result' => empty($messages) ? 'success' : 'failure', 'messages' => $messages, 'reload' => isset(WC()->session->reload_checkout) ? 'true' : 'false', 'fragments' => apply_filters('woocommerce_update_order_review_fragments', array('.woocommerce-checkout-review-order-table' => $woocommerce_order_review, '.woocommerce-checkout-payment' => $woocommerce_checkout_payment)));
wp_send_json($data);
die;
//.........这里部分代码省略.........
示例3: update_order_review
/**
* AJAX update order review on checkout.
*/
public static function update_order_review()
{
check_ajax_referer('update-order-review', 'security');
wc_maybe_define_constant('WOOCOMMERCE_CHECKOUT', true);
if (WC()->cart->is_empty()) {
self::update_order_review_expired();
}
do_action('woocommerce_checkout_update_order_review', $_POST['post_data']);
$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
if (isset($_POST['shipping_method']) && is_array($_POST['shipping_method'])) {
foreach ($_POST['shipping_method'] as $i => $value) {
$chosen_shipping_methods[$i] = wc_clean($value);
}
}
WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
WC()->session->set('chosen_payment_method', empty($_POST['payment_method']) ? '' : $_POST['payment_method']);
WC()->customer->set_props(array('billing_country' => isset($_POST['country']) ? $_POST['country'] : null, 'billing_state' => isset($_POST['state']) ? $_POST['state'] : null, 'billing_postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : null, 'billing_city' => isset($_POST['city']) ? $_POST['city'] : null, 'billing_address_1' => isset($_POST['address']) ? $_POST['address'] : null, 'billing_address_2' => isset($_POST['address_2']) ? $_POST['address_2'] : null));
if (wc_ship_to_billing_address_only()) {
WC()->customer->set_props(array('shipping_country' => isset($_POST['country']) ? $_POST['country'] : null, 'shipping_state' => isset($_POST['state']) ? $_POST['state'] : null, 'shipping_postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : null, 'shipping_city' => isset($_POST['city']) ? $_POST['city'] : null, 'shipping_address_1' => isset($_POST['address']) ? $_POST['address'] : null, 'shipping_address_2' => isset($_POST['address_2']) ? $_POST['address_2'] : null));
if (!empty($_POST['country'])) {
WC()->customer->set_calculated_shipping(true);
}
} else {
WC()->customer->set_props(array('shipping_country' => isset($_POST['s_country']) ? $_POST['s_country'] : null, 'shipping_state' => isset($_POST['s_state']) ? $_POST['s_state'] : null, 'shipping_postcode' => isset($_POST['s_postcode']) ? $_POST['s_postcode'] : null, 'shipping_city' => isset($_POST['s_city']) ? $_POST['s_city'] : null, 'shipping_address_1' => isset($_POST['s_address']) ? $_POST['s_address'] : null, 'shipping_address_2' => isset($_POST['s_address_2']) ? $_POST['s_address_2'] : null));
if (!empty($_POST['s_country'])) {
WC()->customer->set_calculated_shipping(true);
}
}
WC()->customer->save();
WC()->cart->calculate_totals();
// Get order review fragment
ob_start();
woocommerce_order_review();
$woocommerce_order_review = ob_get_clean();
// Get checkout payment fragment
ob_start();
woocommerce_checkout_payment();
$woocommerce_checkout_payment = ob_get_clean();
// Get messages if reload checkout is not true
$messages = '';
if (!isset(WC()->session->reload_checkout)) {
ob_start();
wc_print_notices();
$messages = ob_get_clean();
}
unset(WC()->session->refresh_totals, WC()->session->reload_checkout);
wp_send_json(array('result' => empty($messages) ? 'success' : 'failure', 'messages' => $messages, 'reload' => isset(WC()->session->reload_checkout) ? 'true' : 'false', 'fragments' => apply_filters('woocommerce_update_order_review_fragments', array('.woocommerce-checkout-review-order-table' => $woocommerce_order_review, '.woocommerce-checkout-payment' => $woocommerce_checkout_payment))));
}