woocommerce/shortcodes/shortcode-checkout.php

65 lines
1.5 KiB
PHP
Raw Normal View History

2011-08-10 17:11:11 +00:00
<?php
/**
* Checkout Shortcode
2012-08-14 17:37:50 +00:00
*
2011-08-10 17:11:11 +00:00
* Used on the checkout page, the checkout shortcode displays the checkout process.
*
2012-08-14 17:37:50 +00:00
* @author WooThemes
* @category Shortcodes
* @package WooCommerce/Shortcodes/Checkout
* @version 1.6.4
*/
/**
* Get the checkout shortcode content.
*
* @access public
* @param array $atts
* @return string
2011-08-10 17:11:11 +00:00
*/
function get_woocommerce_checkout( $atts ) {
global $woocommerce;
return $woocommerce->shortcode_wrapper('woocommerce_checkout', $atts);
2011-08-10 17:11:11 +00:00
}
2012-08-14 17:37:50 +00:00
/**
* Output the checkout shortcode.
*
* @access public
* @param array $atts
* @return void
*/
2011-08-10 17:11:11 +00:00
function woocommerce_checkout( $atts ) {
2012-01-12 00:54:45 +00:00
global $woocommerce;
2012-08-14 17:37:50 +00:00
2012-02-24 21:05:15 +00:00
$woocommerce->nocache();
2012-08-14 17:37:50 +00:00
// Show non-cart errors
$woocommerce->show_messages();
2012-08-14 17:37:50 +00:00
// Check cart has contents
if ( sizeof( $woocommerce->cart->get_cart() ) == 0 ) return;
// Calc totals
$woocommerce->cart->calculate_totals();
2012-08-14 17:37:50 +00:00
// Check cart contents for errors
do_action('woocommerce_check_cart_items');
2012-08-14 17:37:50 +00:00
if ( empty( $_POST ) && $woocommerce->error_count() > 0 ) {
2012-08-14 17:37:50 +00:00
2012-02-12 11:36:33 +00:00
woocommerce_get_template('checkout/cart-errors.php');
2012-08-14 17:37:50 +00:00
2012-02-12 11:36:33 +00:00
} else {
2012-08-14 17:37:50 +00:00
2012-07-16 19:21:44 +00:00
$non_js_checkout = ! empty( $_POST['woocommerce_checkout_update_totals'] ) ? true : false;
2012-08-14 17:37:50 +00:00
if ( $woocommerce->error_count() == 0 && $non_js_checkout )
$woocommerce->add_message( __('The order totals have been updated. Please confirm your order by pressing the Place Order button at the bottom of the page.', 'woocommerce') );
2012-08-14 17:37:50 +00:00
2012-02-12 11:36:33 +00:00
woocommerce_get_template('checkout/form-checkout.php');
2012-08-14 17:37:50 +00:00
2012-02-12 11:36:33 +00:00
}
2012-08-14 17:37:50 +00:00
2011-08-10 17:11:11 +00:00
}