Improved template loader

This commit is contained in:
Mike Jolley 2012-02-03 16:17:35 +00:00
parent 85f6d53fab
commit 3b5272e72e
33 changed files with 173 additions and 169 deletions

View File

@ -62,12 +62,12 @@ class WC_Checkout {
/** Output the billing information form */
function checkout_form_billing() {
include( woocommerce_locate_template( 'checkout/form-billing.php' ) );
woocommerce_get_template( 'checkout/form-billing.php', array( 'checkout' => $this ) );
}
/** Output the shipping information form */
function checkout_form_shipping() {
include( woocommerce_locate_template( 'checkout/form-shipping.php' ) );
woocommerce_get_template( 'checkout/form-shipping.php', array( 'checkout' => $this ) );
}
/**

View File

@ -66,12 +66,12 @@ class WC_Email {
return 'text/html';
}
function email_header() {
woocommerce_get_template('emails/email-header.php', false);
function email_header( $email_heading ) {
woocommerce_get_template('emails/email-header.php', array( 'email_heading' => $email_heading ));
}
function email_footer() {
woocommerce_get_template('emails/email-footer.php', false);
woocommerce_get_template('emails/email-footer.php');
}
/**
@ -81,7 +81,7 @@ class WC_Email {
// Buffer
ob_start();
do_action('woocommerce_email_header');
do_action('woocommerce_email_header', $email_heading);
echo wpautop(wptexturize( $message ));
@ -114,7 +114,6 @@ class WC_Email {
* New order
**/
function new_order( $order_id ) {
global $order, $email_heading;
$order = new WC_Order( $order_id );
@ -128,7 +127,10 @@ class WC_Email {
ob_start();
// Get mail template
woocommerce_get_template('emails/admin-new-order.php', false);
woocommerce_get_template('emails/admin-new-order.php', array(
'order' => $order,
'email_heading' => $email_heading
));
// Get contents
$message = ob_get_clean();
@ -141,7 +143,6 @@ class WC_Email {
* Processing Order
**/
function customer_processing_order( $order_id ) {
global $order, $email_heading;
$order = new WC_Order( $order_id );
@ -155,7 +156,10 @@ class WC_Email {
ob_start();
// Get mail template
woocommerce_get_template('emails/customer-processing-order.php', false);
woocommerce_get_template('emails/customer-processing-order.php', array(
'order' => $order,
'email_heading' => $email_heading
));
// Get contents
$message = ob_get_clean();
@ -171,7 +175,6 @@ class WC_Email {
* Completed Order
**/
function customer_completed_order( $order_id ) {
global $order, $email_heading;
$order = new WC_Order( $order_id );
@ -193,7 +196,10 @@ class WC_Email {
ob_start();
// Get mail template
woocommerce_get_template('emails/customer-completed-order.php', false);
woocommerce_get_template('emails/customer-completed-order.php', array(
'order' => $order,
'email_heading' => $email_heading
));
// Get contents
$message = ob_get_clean();
@ -209,7 +215,6 @@ class WC_Email {
* Pay for order - invoice
**/
function customer_invoice( $pay_for_order ) {
global $order, $email_heading;
$order = $pay_for_order;
@ -223,7 +228,10 @@ class WC_Email {
ob_start();
// Get mail template
woocommerce_get_template('emails/customer-invoice.php', false);
woocommerce_get_template('emails/customer-invoice.php', array(
'order' => $order,
'email_heading' => $email_heading
));
// Get contents
$message = ob_get_clean();
@ -239,7 +247,6 @@ class WC_Email {
* Customer notes
**/
function customer_note( $args ) {
global $order, $email_heading, $customer_note;
$defaults = array(
'order_id' => '',
@ -264,7 +271,11 @@ class WC_Email {
ob_start();
// Get mail template
woocommerce_get_template('emails/customer-note.php', false);
woocommerce_get_template('emails/customer-note.php', array(
'order' => $order,
'email_heading' => $email_heading,
'customer_note' => $customer_note
));
// Get contents
$message = ob_get_clean();
@ -362,7 +373,6 @@ class WC_Email {
* Customer new account welcome email
**/
function customer_new_account( $user_id, $plaintext_pass ) {
global $user_login, $user_pass, $blogname;
if (!$user_id || !$plaintext_pass) return;
@ -381,7 +391,12 @@ class WC_Email {
ob_start();
// Get mail template
woocommerce_get_template('emails/customer-new-account.php', false);
woocommerce_get_template('emails/customer-new-account.php', array(
'user_login' => $user_login,
'user_pass' => $user_pass,
'blogname' => $blogname,
'email_heading' => $email_heading
));
// Get contents
$message = ob_get_clean();

View File

@ -84,6 +84,7 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
= 1.4.2 =
* Uninstall fix
* Improved template loader - passes args instead of using globals
= 1.4.1 - 01/02/2012 =
* Depreciated tax class fix

View File

@ -25,5 +25,5 @@ function woocommerce_checkout( $atts ) {
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') );
woocommerce_get_template('checkout/form-checkout.php', false);
woocommerce_get_template('checkout/form-checkout.php');
}

View File

@ -36,7 +36,7 @@ function get_woocommerce_view_order() {
* @since 1.4
*/
function woocommerce_my_account( $atts ) {
global $woocommerce, $current_user, $recent_orders;
global $woocommerce, $current_user;
if ( ! is_user_logged_in() ) :
@ -52,7 +52,10 @@ function woocommerce_my_account( $atts ) {
get_currentuserinfo();
woocommerce_get_template( 'myaccount/my-account.php' );
woocommerce_get_template( 'myaccount/my-account.php', array(
'current_user' => $current_user,
'recent_orders' => $recent_orders
) );
endif;
@ -70,7 +73,7 @@ function woocommerce_my_account( $atts ) {
* @since 1.4
*/
function woocommerce_edit_address() {
global $woocommerce, $load_address, $address;
global $woocommerce;
if ( ! is_user_logged_in() ) return;
@ -78,7 +81,10 @@ function woocommerce_edit_address() {
$address = $woocommerce->countries->get_address_fields( get_user_meta( get_current_user_id(), $load_address . '_country', true ), $load_address . '_' );
woocommerce_get_template( 'myaccount/form-edit-address.php' );
woocommerce_get_template( 'myaccount/form-edit-address.php', array(
'load_address' => $load_address,
'address' => $address
) );
}
/**

View File

@ -14,7 +14,7 @@ function get_woocommerce_order_tracking($atts) {
}
function woocommerce_order_tracking( $atts ) {
global $woocommerce, $order;
global $woocommerce;
extract(shortcode_atts(array(
), $atts));
@ -34,7 +34,9 @@ function woocommerce_order_tracking( $atts ) {
if ($order->billing_email == $order_email) :
woocommerce_get_template( 'order/tracking.php' );
woocommerce_get_template( 'order/tracking.php', array(
'order' => $order
) );
return;

View File

@ -18,7 +18,7 @@ function get_woocommerce_pay( $atts ) {
* Outputs the pay page - payment gateways can hook in here to show payment forms etc
**/
function woocommerce_pay() {
global $woocommerce, $order;
global $woocommerce;
if ( isset($_GET['pay_for_order']) && isset($_GET['order']) && isset($_GET['order_id']) ) :
@ -35,7 +35,7 @@ function woocommerce_pay() {
if ($order->billing_postcode) $woocommerce->customer->set_postcode( $order->billing_postcode );
// Show form
woocommerce_get_template('checkout/form-pay.php');
woocommerce_get_template('checkout/form-pay.php', array('order' => $order));
elseif (!in_array($order->status, array('pending', 'failed'))) :

View File

@ -18,7 +18,7 @@ function get_woocommerce_thankyou( $atts ) {
* Outputs the order received page
**/
function woocommerce_thankyou( $atts ) {
global $woocommerce, $order;
global $woocommerce;
$order = false;
@ -36,5 +36,5 @@ function woocommerce_thankyou( $atts ) {
endif;
endif;
woocommerce_get_template( 'checkout/thankyou.php' );
woocommerce_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
}

View File

@ -15,22 +15,22 @@ global $woocommerce;
<?php endif; ?>
<?php do_action('woocommerce_before_checkout_billing_form', $this); ?>
<?php do_action('woocommerce_before_checkout_billing_form', $checkout); ?>
<?php foreach ($this->checkout_fields['billing'] as $key => $field) : ?>
<?php foreach ($checkout->checkout_fields['billing'] as $key => $field) : ?>
<?php woocommerce_form_field( $key, $field, $this->get_value( $key ) ); ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
<?php do_action('woocommerce_after_checkout_billing_form', $this); ?>
<?php do_action('woocommerce_after_checkout_billing_form', $checkout); ?>
<?php if (!is_user_logged_in() && get_option('woocommerce_enable_signup_and_login_from_checkout')=="yes") : ?>
<?php if (get_option('woocommerce_enable_guest_checkout')=='yes') : ?>
<p class="form-row">
<input class="input-checkbox" id="createaccount" <?php checked($this->get_value('createaccount'), true) ?> type="checkbox" name="createaccount" value="1" /> <label for="createaccount" class="checkbox"><?php _e('Create an account?', 'woocommerce'); ?></label>
<input class="input-checkbox" id="createaccount" <?php checked($checkout->get_value('createaccount'), true) ?> type="checkbox" name="createaccount" value="1" /> <label for="createaccount" class="checkbox"><?php _e('Create an account?', 'woocommerce'); ?></label>
</p>
<?php endif; ?>
@ -39,9 +39,9 @@ global $woocommerce;
<p><?php _e('Create an account by entering the information below. If you are a returning customer please login with your username at the top of the page.', 'woocommerce'); ?></p>
<?php foreach ($this->checkout_fields['account'] as $key => $field) : ?>
<?php foreach ($checkout->checkout_fields['account'] as $key => $field) : ?>
<?php woocommerce_form_field( $key, $field, $this->get_value( $key ) ); ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>

View File

@ -2,7 +2,7 @@
/**
* Pay for order form
*/
global $order, $woocommerce;
global $woocommerce;
?>
<form id="order_review" method="post">

View File

@ -15,7 +15,7 @@ global $woocommerce;
else :
$shiptobilling = $this->get_value('shiptobilling');
$shiptobilling = $checkout->get_value('shiptobilling');
endif;
?>
@ -28,21 +28,21 @@ global $woocommerce;
<div class="shipping_address">
<?php do_action('woocommerce_before_checkout_shipping_form', $this); ?>
<?php do_action('woocommerce_before_checkout_shipping_form', $checkout); ?>
<?php foreach ($this->checkout_fields['shipping'] as $key => $field) : ?>
<?php foreach ($checkout->checkout_fields['shipping'] as $key => $field) : ?>
<?php woocommerce_form_field( $key, $field, $this->get_value( $key ) ); ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
<?php do_action('woocommerce_after_checkout_shipping_form', $this); ?>
<?php do_action('woocommerce_after_checkout_shipping_form', $checkout); ?>
</div>
<?php endif; ?>
<?php do_action('woocommerce_before_order_notes', $this); ?>
<?php do_action('woocommerce_before_order_notes', $checkout); ?>
<?php if (get_option('woocommerce_enable_order_comments')!='no') : ?>
@ -52,12 +52,12 @@ global $woocommerce;
<?php endif; ?>
<?php foreach ($this->checkout_fields['order'] as $key => $field) : ?>
<?php foreach ($checkout->checkout_fields['order'] as $key => $field) : ?>
<?php woocommerce_form_field( $key, $field, $this->get_value( $key ) ); ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
<?php endif; ?>
<?php do_action('woocommerce_after_order_notes', $this); ?>
<?php do_action('woocommerce_after_order_notes', $checkout); ?>

View File

@ -3,7 +3,7 @@
* Thankyou Page
*/
global $woocommerce, $order;
global $woocommerce;
?>
<?php if ($order) : ?>

View File

@ -1,8 +1,6 @@
<?php if (!defined('ABSPATH')) exit; ?>
<?php global $order; ?>
<?php do_action('woocommerce_email_header'); ?>
<?php do_action('woocommerce_email_header', $email_heading); ?>
<p><?php echo __('You have received an order from', 'woocommerce') . ' ' . $order->billing_first_name . ' ' . $order->billing_last_name . __(". Their order is as follows:", 'woocommerce'); ?></p>

View File

@ -1,8 +1,6 @@
<?php if (!defined('ABSPATH')) exit; ?>
<?php global $order_id, $order, $woocommerce; ?>
<?php do_action('woocommerce_email_header'); ?>
<?php do_action('woocommerce_email_header', $email_heading); ?>
<p><?php _e("Your order is complete. Your order's details are below:", 'woocommerce'); ?></p>

View File

@ -1,8 +1,6 @@
<?php if (!defined('ABSPATH')) exit; ?>
<?php global $order, $woocommerce; ?>
<?php do_action('woocommerce_email_header'); ?>
<?php do_action('woocommerce_email_header', $email_heading); ?>
<?php if ($order->status=='pending') : ?>

View File

@ -1,8 +1,6 @@
<?php if (!defined('ABSPATH')) exit; ?>
<?php global $user_login, $user_pass, $blogname; ?>
<?php do_action('woocommerce_email_header'); ?>
<?php do_action('woocommerce_email_header', $email_heading); ?>
<p><?php echo sprintf(__("Thanks for registering on %s. Your login details are below:", 'woocommerce'), $blogname); ?></p>

View File

@ -1,8 +1,6 @@
<?php if (!defined('ABSPATH')) exit; ?>
<?php global $order_id, $order, $customer_note, $woocommerce; ?>
<?php do_action('woocommerce_email_header'); ?>
<?php do_action('woocommerce_email_header', $email_heading); ?>
<p><?php _e("Hello, a note has just been added to your order:", 'woocommerce'); ?></p>

View File

@ -1,8 +1,6 @@
<?php if (!defined('ABSPATH')) exit; ?>
<?php global $order; ?>
<?php do_action('woocommerce_email_header'); ?>
<?php do_action('woocommerce_email_header', $email_heading); ?>
<p><?php _e("Thank you, we are now processing your order. Your order's details are below.", 'woocommerce'); ?></p>

View File

@ -165,7 +165,6 @@
<!-- // Begin Module: Standard Header Image \\ -->
<h1 class="h1" style="color:<?php echo woocommerce_light_or_dark(get_option('woocommerce_email_base_color'), '#202020', '#ffffff'); ?> !important; margin:0; text-shadow:0 1px 0 <?php echo woocommerce_hex_lighter(get_option('woocommerce_email_base_color'), 20); ?>;"><?php
global $email_heading;
echo $email_heading;
?></h1>
<!-- // End Module: Standard Header Image \\ -->

View File

@ -1,4 +1,10 @@
<?php global $woocommerce, $woocommerce_loop, $product_categories, $product_category_found, $product_category_parent; ?>
<?php
global $woocommerce, $woocommerce_loop, $product_category_found;
$product_category_found = false;
?>
<?php
foreach ($product_categories as $category) :
@ -8,7 +14,6 @@ foreach ($product_categories as $category) :
$product_category_found = true;
$woocommerce_loop['loop']++;
?>
<li class="product sub-category <?php if ($woocommerce_loop['loop']%$woocommerce_loop['columns']==0) echo 'last'; if (($woocommerce_loop['loop']-1)%$woocommerce_loop['columns']==0) echo 'first'; ?>">

View File

@ -3,7 +3,7 @@
* Edit Address Form
*/
global $woocommerce, $load_address, $address;
global $woocommerce;
?>
<?php $woocommerce->show_messages(); ?>

View File

@ -3,7 +3,7 @@
* My Account
*/
global $woocommerce, $current_user, $recent_orders;
global $woocommerce;
?>
<?php $woocommerce->show_messages(); ?>

View File

@ -3,7 +3,7 @@
* Order Details
*/
global $woocommerce, $order_id;
global $woocommerce;
$order = new WC_Order( $order_id );
?>

View File

@ -3,7 +3,7 @@
* Order Tracking
*/
global $woocommerce, $order;
global $woocommerce;
?>
<?php

View File

@ -3,7 +3,7 @@
* Shop Breadcrumb
*/
global $post, $wp_query, $author, $paged, $delimiter, $wrap_before, $wrap_after, $before, $after, $home;
global $post, $wp_query;
if( !$home ) $home = _x('Home', 'breadcrumb', 'woocommerce');

View File

@ -3,7 +3,7 @@
* Login Form
*/
global $message, $redirect, $woocommerce;
global $woocommerce;
if (is_user_logged_in()) return;
?>

View File

@ -1,9 +1 @@
<?php
/**
* Shop Sidebar
*
* Simply loads your sidebar, or sidebar-shop.php if it exists
*/
get_sidebar('shop');
?>
<?php get_sidebar('shop'); ?>

View File

@ -2,7 +2,5 @@
/**
* Single Product Quantity Inputs
*/
global $input_name, $input_value, $max_value;
?>
<div class="quantity"><input name="<?php echo $input_name; ?>" data-max="<?php echo $max_value; ?>" value="<?php echo $input_value; ?>" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div>

View File

@ -3,7 +3,7 @@
* Variable Product Add to Cart
*/
global $woocommerce, $product, $available_variations, $attributes, $selected_attributes;
global $woocommerce, $product;
?>
<script type="text/javascript">
var product_variations = <?php echo json_encode($available_variations) ?>;

View File

@ -3,7 +3,7 @@
* Related Products
*/
global $product, $woocommerce_loop, $posts_per_page, $orderby;
global $product, $woocommerce_loop;
$related = $product->get_related();
@ -12,15 +12,20 @@ if (sizeof($related)==0) return;
<div class="related products"><h2><?php _e('Related Products', 'woocommerce'); ?></h2>
<?php
$args = array(
'post_type' => 'product',
'post_type' => 'product',
'ignore_sticky_posts' => 1,
'posts_per_page' => $posts_per_page,
'orderby' => $orderby,
'post__in' => $related
'posts_per_page' => $posts_per_page,
'orderby' => $orderby,
'post__in' => $related
);
$args = apply_filters('woocommerce_related_products_args', $args);
query_posts($args);
$woocommerce_loop['columns'] = $columns;
woocommerce_get_template_part( 'loop', 'shop' );
wp_reset_query();
?>
</div>

View File

@ -2,7 +2,7 @@
/**
* Review Comments Template
*
* Closesing li is left out on purpose!
* Closing li is left out on purpose!
*/
global $post;

View File

@ -114,27 +114,27 @@ function woocommerce_get_template_part( $slug, $name = '' ) {
}
/**
* Get other templates (e.g. product attributes)
* Get other templates (e.g. product attributes) passing attributes and including the file
*/
function woocommerce_get_template($template_name, $require_once = true) {
function woocommerce_get_template($template_name, $args = array()) {
global $woocommerce;
if (file_exists( STYLESHEETPATH . '/' . $woocommerce->template_url . $template_name ))
load_template( STYLESHEETPATH . '/' . $woocommerce->template_url . $template_name, $require_once );
elseif (file_exists( STYLESHEETPATH . '/' . $template_name ))
load_template( STYLESHEETPATH . '/' . $template_name , $require_once);
else
load_template( $woocommerce->plugin_path() . '/templates/' . $template_name , $require_once);
if ( $args && is_array($args) )
extract( $args );
include( woocommerce_locate_template( $template_name ) );
}
/**
* Locate a template and return the path for inclusion - this lets us pass variables to the template easier than wth get_template_part
* Locate a template and return the path for inclusion
*/
function woocommerce_locate_template( $template_name ) {
global $woocommerce;
$template = locate_template( $woocommerce->template_url . $template_name );
// Look in yourtheme/woocommerce/template-name and yourtheme/template-name
$template = locate_template( array( $woocommerce->template_url . $template_name , $template_name ) );
// Get default template
if (!$template) $template = $woocommerce->plugin_path() . '/templates/' . $template_name;
return $template;

View File

@ -108,12 +108,12 @@ if (!function_exists('woocommerce_single_product_content')) {
if (!function_exists('woocommerce_output_content_wrapper')) {
function woocommerce_output_content_wrapper() {
woocommerce_get_template('shop/wrapper-start.php', false);
woocommerce_get_template('shop/wrapper-start.php');
}
}
if (!function_exists('woocommerce_output_content_wrapper_end')) {
function woocommerce_output_content_wrapper_end() {
woocommerce_get_template('shop/wrapper-end.php', false);
woocommerce_get_template('shop/wrapper-end.php');
}
}
@ -122,7 +122,7 @@ if (!function_exists('woocommerce_output_content_wrapper_end')) {
**/
if (!function_exists('woocommerce_get_sidebar')) {
function woocommerce_get_sidebar() {
woocommerce_get_template('shop/sidebar.php', false);
woocommerce_get_template('shop/sidebar.php');
}
}
@ -155,7 +155,7 @@ if (!function_exists('woocommerce_demo_store')) {
**/
if (!function_exists('woocommerce_template_loop_add_to_cart')) {
function woocommerce_template_loop_add_to_cart() {
woocommerce_get_template('loop/add-to-cart.php', false);
woocommerce_get_template('loop/add-to-cart.php');
}
}
if (!function_exists('woocommerce_template_loop_product_thumbnail')) {
@ -165,12 +165,12 @@ if (!function_exists('woocommerce_template_loop_product_thumbnail')) {
}
if (!function_exists('woocommerce_template_loop_price')) {
function woocommerce_template_loop_price() {
woocommerce_get_template('loop/price.php', false);
woocommerce_get_template('loop/price.php');
}
}
if (!function_exists('woocommerce_show_product_loop_sale_flash')) {
function woocommerce_show_product_loop_sale_flash() {
woocommerce_get_template('loop/sale-flash.php', false);
woocommerce_get_template('loop/sale-flash.php');
}
}
@ -193,7 +193,7 @@ if (!function_exists('woocommerce_get_product_thumbnail')) {
**/
if (!function_exists('woocommerce_pagination')) {
function woocommerce_pagination() {
woocommerce_get_template('loop/pagination.php', false);
woocommerce_get_template('loop/pagination.php');
}
}
@ -203,7 +203,7 @@ if (!function_exists('woocommerce_pagination')) {
if (!function_exists('woocommerce_catalog_ordering')) {
function woocommerce_catalog_ordering() {
if (!isset($_SESSION['orderby'])) $_SESSION['orderby'] = apply_filters('woocommerce_default_catalog_orderby', 'title');
woocommerce_get_template('loop/sorting.php', false);
woocommerce_get_template('loop/sorting.php');
}
}
@ -214,42 +214,42 @@ if (!function_exists('woocommerce_catalog_ordering')) {
**/
if (!function_exists('woocommerce_show_product_images')) {
function woocommerce_show_product_images() {
woocommerce_get_template('single-product/product-image.php', false);
woocommerce_get_template('single-product/product-image.php');
}
}
if (!function_exists('woocommerce_show_product_thumbnails')) {
function woocommerce_show_product_thumbnails() {
woocommerce_get_template('single-product/product-thumbnails.php', false);
woocommerce_get_template('single-product/product-thumbnails.php');
}
}
if (!function_exists('woocommerce_output_product_data_tabs')) {
function woocommerce_output_product_data_tabs() {
woocommerce_get_template('single-product/tabs.php', false);
woocommerce_get_template('single-product/tabs.php');
}
}
if (!function_exists('woocommerce_template_single_price')) {
function woocommerce_template_single_price() {
woocommerce_get_template('single-product/price.php', false);
woocommerce_get_template('single-product/price.php');
}
}
if (!function_exists('woocommerce_template_single_excerpt')) {
function woocommerce_template_single_excerpt() {
woocommerce_get_template('single-product/short-description.php', false);
woocommerce_get_template('single-product/short-description.php');
}
}
if (!function_exists('woocommerce_template_single_meta')) {
function woocommerce_template_single_meta() {
woocommerce_get_template('single-product/meta.php', false);
woocommerce_get_template('single-product/meta.php');
}
}
if (!function_exists('woocommerce_template_single_sharing')) {
function woocommerce_template_single_sharing() {
woocommerce_get_template('single-product/share.php', false);
woocommerce_get_template('single-product/share.php');
}
}
if (!function_exists('woocommerce_show_product_sale_flash')) {
function woocommerce_show_product_sale_flash() {
woocommerce_get_template('single-product/sale-flash.php', false);
woocommerce_get_template('single-product/sale-flash.php');
}
}
@ -264,17 +264,17 @@ if (!function_exists('woocommerce_template_single_add_to_cart')) {
}
if (!function_exists('woocommerce_simple_add_to_cart')) {
function woocommerce_simple_add_to_cart() {
woocommerce_get_template('single-product/add-to-cart/simple.php', false);
woocommerce_get_template('single-product/add-to-cart/simple.php');
}
}
if (!function_exists('woocommerce_grouped_add_to_cart')) {
function woocommerce_grouped_add_to_cart() {
woocommerce_get_template('single-product/add-to-cart/grouped.php', false);
woocommerce_get_template('single-product/add-to-cart/grouped.php');
}
}
if (!function_exists('woocommerce_variable_add_to_cart')) {
function woocommerce_variable_add_to_cart() {
global $woocommerce, $available_variations, $attributes, $selected_attributes, $product, $post;
global $woocommerce, $product, $post;
$attributes = $product->get_available_attribute_variations();
$default_attributes = (array) maybe_unserialize(get_post_meta( $post->ID, '_default_attributes', true ));
@ -316,12 +316,16 @@ if (!function_exists('woocommerce_variable_add_to_cart')) {
);
}
}
woocommerce_get_template('single-product/add-to-cart/variable.php', false);
woocommerce_get_template('single-product/add-to-cart/variable.php', array(
'available_variations' => $available_variations,
'attributes' => $attributes,
'selected_attributes' => $selected_attributes,
));
}
}
if (!function_exists('woocommerce_external_add_to_cart')) {
function woocommerce_external_add_to_cart() {
woocommerce_get_template('single-product/add-to-cart/external.php', false);
woocommerce_get_template('single-product/add-to-cart/external.php');
}
}
@ -330,8 +334,6 @@ if (!function_exists('woocommerce_external_add_to_cart')) {
**/
if (!function_exists('woocommerce_quantity_input')) {
function woocommerce_quantity_input( $args = array() ) {
global $input_name, $input_value, $max_value;
$defaults = array(
'input_name' => 'quantity',
'input_value' => '1',
@ -339,10 +341,8 @@ if (!function_exists('woocommerce_quantity_input')) {
);
$args = wp_parse_args( $args, $defaults );
extract( $args );
woocommerce_get_template('single-product/add-to-cart/quantity.php', false);
woocommerce_get_template('single-product/add-to-cart/quantity.php', $args);
}
}
@ -351,17 +351,17 @@ if (!function_exists('woocommerce_quantity_input')) {
**/
if (!function_exists('woocommerce_product_description_tab')) {
function woocommerce_product_description_tab() {
woocommerce_get_template('single-product/tabs/tab-description.php', false);
woocommerce_get_template('single-product/tabs/tab-description.php');
}
}
if (!function_exists('woocommerce_product_attributes_tab')) {
function woocommerce_product_attributes_tab() {
woocommerce_get_template('single-product/tabs/tab-attributes.php', false);
woocommerce_get_template('single-product/tabs/tab-attributes.php');
}
}
if (!function_exists('woocommerce_product_reviews_tab')) {
function woocommerce_product_reviews_tab() {
woocommerce_get_template('single-product/tabs/tab-reviews.php', false);
woocommerce_get_template('single-product/tabs/tab-reviews.php');
}
}
@ -370,17 +370,17 @@ if (!function_exists('woocommerce_product_reviews_tab')) {
**/
if (!function_exists('woocommerce_product_description_panel')) {
function woocommerce_product_description_panel() {
woocommerce_get_template('single-product/tabs/description.php', false);
woocommerce_get_template('single-product/tabs/description.php');
}
}
if (!function_exists('woocommerce_product_attributes_panel')) {
function woocommerce_product_attributes_panel() {
woocommerce_get_template('single-product/tabs/attributes.php', false);
woocommerce_get_template('single-product/tabs/attributes.php');
}
}
if (!function_exists('woocommerce_product_reviews_panel')) {
function woocommerce_product_reviews_panel() {
woocommerce_get_template('single-product/tabs/reviews.php', false);
woocommerce_get_template('single-product/tabs/reviews.php');
}
}
@ -390,7 +390,7 @@ if (!function_exists('woocommerce_product_reviews_panel')) {
if (!function_exists('woocommerce_comments')) {
function woocommerce_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
woocommerce_get_template('single-product/review.php', false);
woocommerce_get_template('single-product/review.php');
}
}
@ -404,14 +404,12 @@ if (!function_exists('woocommerce_output_related_products')) {
}
if (!function_exists('woocommerce_related_products')) {
function woocommerce_related_products( $pp = 4, $pc = 4, $ob = 'rand' ) {
global $product, $woocommerce_loop, $posts_per_page, $orderby;
$woocommerce_loop['columns'] = $pc;
$posts_per_page = $pp;
$orderby = $ob;
woocommerce_get_template('single-product/related.php', false);
function woocommerce_related_products( $posts_per_page = 4, $columns = 4, $orderby = 'rand' ) {
woocommerce_get_template('single-product/related.php', array(
'posts_per_page' => $posts_per_page,
'orderby' => $orderby,
'columns' => $columns
));
}
}
@ -420,7 +418,7 @@ if (!function_exists('woocommerce_related_products')) {
**/
if (!function_exists('woocommerce_upsell_display')) {
function woocommerce_upsell_display() {
woocommerce_get_template('single-product/up-sells.php', false);
woocommerce_get_template('single-product/up-sells.php');
}
}
@ -431,7 +429,7 @@ if (!function_exists('woocommerce_upsell_display')) {
**/
if (!function_exists('woocommerce_shipping_calculator')) {
function woocommerce_shipping_calculator() {
woocommerce_get_template('cart/shipping-calculator.php', false);
woocommerce_get_template('cart/shipping-calculator.php');
}
}
@ -440,7 +438,7 @@ if (!function_exists('woocommerce_shipping_calculator')) {
**/
if (!function_exists('woocommerce_cart_totals')) {
function woocommerce_cart_totals() {
woocommerce_get_template('cart/totals.php', false);
woocommerce_get_template('cart/totals.php');
}
}
@ -449,7 +447,7 @@ if (!function_exists('woocommerce_cart_totals')) {
**/
if (!function_exists('woocommerce_cross_sell_display')) {
function woocommerce_cross_sell_display() {
woocommerce_get_template('cart/cross-sells.php', false);
woocommerce_get_template('cart/cross-sells.php');
}
}
@ -460,18 +458,15 @@ if (!function_exists('woocommerce_cross_sell_display')) {
**/
if (!function_exists('woocommerce_login_form')) {
function woocommerce_login_form( $args = array() ) {
global $message, $redirect;
$defaults = array(
'message' => '',
'redirect' => ''
);
$args = wp_parse_args( $args, $defaults );
extract( $args );
woocommerce_get_template('shop/form-login.php', false);
woocommerce_get_template('shop/form-login.php', $args);
}
}
@ -480,7 +475,7 @@ if (!function_exists('woocommerce_login_form')) {
**/
if (!function_exists('woocommerce_checkout_login_form')) {
function woocommerce_checkout_login_form() {
woocommerce_get_template('checkout/form-login.php', false);
woocommerce_get_template('checkout/form-login.php');
}
}
@ -489,7 +484,6 @@ if (!function_exists('woocommerce_checkout_login_form')) {
**/
if (!function_exists('woocommerce_breadcrumb')) {
function woocommerce_breadcrumb( $args = array() ) {
global $delimiter, $wrap_before, $wrap_after, $before, $after, $home;
$defaults = array(
'delimiter' => ' &rsaquo; ',
@ -501,10 +495,8 @@ if (!function_exists('woocommerce_breadcrumb')) {
);
$args = wp_parse_args( $args, $defaults );
extract( $args );
woocommerce_get_template('shop/breadcrumb.php', false);
woocommerce_get_template('shop/breadcrumb.php', $args);
}
}
@ -513,7 +505,7 @@ if (!function_exists('woocommerce_breadcrumb')) {
**/
if (!function_exists('woocommerce_order_review')) {
function woocommerce_order_review() {
woocommerce_get_template('checkout/review-order.php', false);
woocommerce_get_template('checkout/review-order.php');
}
}
@ -522,7 +514,7 @@ if (!function_exists('woocommerce_order_review')) {
**/
if (!function_exists('woocommerce_checkout_coupon_form')) {
function woocommerce_checkout_coupon_form() {
woocommerce_get_template('checkout/form-coupon.php', false);
woocommerce_get_template('checkout/form-coupon.php');
}
}
@ -531,7 +523,7 @@ if (!function_exists('woocommerce_checkout_coupon_form')) {
**/
if (!function_exists('woocommerce_product_subcategories')) {
function woocommerce_product_subcategories() {
global $woocommerce, $woocommerce_loop, $wp_query, $wp_the_query, $_chosen_attributes, $product_categories, $product_category_found, $product_category_parent;
global $woocommerce, $woocommerce_loop, $wp_query, $wp_the_query, $_chosen_attributes, $product_category_found;
if ($wp_query !== $wp_the_query) return; // Detect main query
if (sizeof($_chosen_attributes)>0 || (isset($_GET['max_price']) && isset($_GET['min_price']))) return; // Don't show when filtering
@ -561,7 +553,10 @@ if (!function_exists('woocommerce_product_subcategories')) {
if ($product_categories) :
woocommerce_get_template('loop-product-cats.php', false);
woocommerce_get_template('loop-product-cats.php', array(
'product_categories' => $product_categories,
'product_category_parent' => $product_category_parent
));
// If we are hiding products disable the loop and pagination
if ($product_category_found==true && get_option('woocommerce_hide_products_when_showing_subcategories')=='yes') :
@ -601,14 +596,12 @@ if (!function_exists('woocommerce_subcategory_thumbnail')) {
* Displays order details in a table
**/
if (!function_exists('woocommerce_order_details_table')) {
function woocommerce_order_details_table( $id ) {
global $order_id;
if (!$id) return;
$order_id = $id;
woocommerce_get_template('order/order-details.php', false);
function woocommerce_order_details_table( $order_id ) {
if (!$order_id) return;
woocommerce_get_template('order/order-details.php', array(
'order_id' => $order_id
));
}
}