Genesis compat

This commit is contained in:
Mike Jolley 2011-12-08 14:53:14 +00:00
parent 2d2c5e74c3
commit 83df25bb68
3 changed files with 27 additions and 25 deletions

View File

@ -1,6 +1,6 @@
<?php get_header('shop'); ?>
<?php do_action('woocommerce_before_main_content'); // <div id="container"><div id="content" role="main"> ?>
<?php do_action('woocommerce_before_main_content'); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); global $_product; $_product = &new woocommerce_product( $post->ID ); ?>

View File

@ -33,6 +33,7 @@ add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop
add_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10);
/* Before Single Products */
add_action( 'woocommerce_before_single_product', 'woocommerce_before_single_product', 10, 2);
add_action( 'woocommerce_before_single_product', 'woocommerce_check_product_visibility', 10, 2);
/* Before Single Products Summary Div */
@ -54,10 +55,10 @@ add_action('woocommerce_after_single_product', 'woocommerce_upsell_display');
/* Product Add to cart */
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30, 2 );
add_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart' );
add_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart' );
add_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart' );
add_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart' );
add_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30, 2 );
add_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30, 2 );
add_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30, 2 );
add_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30, 2 );
/* Product Add to Cart forms */
add_action( 'woocommerce_add_to_cart_form', 'woocommerce_add_to_cart_form_nonce', 10);

View File

@ -31,6 +31,17 @@ if (!function_exists('woocommerce_output_content_wrapper_end')) {
}
}
/**
* Compatibility (for globals)
*
* Genisis shows products via an action, so ensure the $_product variable is set
**/
function woocommerce_before_single_product( $post, $product ) {
global $_product;
if (is_null($_product)) $_product = $product;
}
/**
* Sale Flash
**/
@ -116,7 +127,7 @@ if (!function_exists('woocommerce_check_product_visibility')) {
if (!function_exists('woocommerce_show_product_images')) {
function woocommerce_show_product_images() {
global $_product, $post, $woocommerce;
global $post, $woocommerce;
echo '<div class="images">';
@ -140,7 +151,7 @@ if (!function_exists('woocommerce_show_product_images')) {
if (!function_exists('woocommerce_show_product_thumbnails')) {
function woocommerce_show_product_thumbnails() {
global $_product, $post;
global $post;
echo '<div class="thumbnails">';
@ -274,13 +285,13 @@ if (!function_exists('woocommerce_sharethis_script')) {
**/
if (!function_exists('woocommerce_template_single_add_to_cart')) {
function woocommerce_template_single_add_to_cart( $post, $_product ) {
do_action( 'woocommerce_' . $_product->product_type . '_add_to_cart' );
do_action( 'woocommerce_' . $_product->product_type . '_add_to_cart', $post, $_product );
}
}
if (!function_exists('woocommerce_simple_add_to_cart')) {
function woocommerce_simple_add_to_cart() {
function woocommerce_simple_add_to_cart( $post, $_product ) {
global $_product; $availability = $_product->get_availability();
$availability = $_product->get_availability();
// No price set - so no button
if( $_product->get_price() === '') return;
@ -318,12 +329,9 @@ if (!function_exists('woocommerce_simple_add_to_cart')) {
}
}
if (!function_exists('woocommerce_grouped_add_to_cart')) {
function woocommerce_grouped_add_to_cart() {
function woocommerce_grouped_add_to_cart( $post, $_product ) {
global $_product;
?>
<?php do_action('woocommerce_before_add_to_cart_form'); ?>
do_action('woocommerce_before_add_to_cart_form'); ?>
<form action="<?php echo esc_url( $_product->add_to_cart_url() ); ?>" class="cart" method="post" enctype='multipart/form-data'>
<table cellspacing="0" class="group_table">
@ -357,9 +365,8 @@ if (!function_exists('woocommerce_grouped_add_to_cart')) {
}
}
if (!function_exists('woocommerce_variable_add_to_cart')) {
function woocommerce_variable_add_to_cart() {
global $post, $_product, $woocommerce;
function woocommerce_variable_add_to_cart( $post, $_product ) {
global $woocommerce;
$attributes = $_product->get_available_attribute_variations();
$default_attributes = (array) maybe_unserialize(get_post_meta( $post->ID, '_default_attributes', true ));
@ -461,9 +468,7 @@ if (!function_exists('woocommerce_variable_add_to_cart')) {
}
}
if (!function_exists('woocommerce_external_add_to_cart')) {
function woocommerce_external_add_to_cart() {
global $_product;
function woocommerce_external_add_to_cart( $post, $_product ) {
$product_url = get_post_meta( $_product->id, 'product_url', true );
if (!$product_url) return;
@ -564,11 +569,8 @@ if (!function_exists('woocommerce_product_description_tab')) {
}
if (!function_exists('woocommerce_product_attributes_tab')) {
function woocommerce_product_attributes_tab() {
global $_product;
if ($_product->has_attributes()) : ?><li><a href="#tab-attributes"><?php _e('Additional Information', 'woothemes'); ?></a></li><?php endif;
}
}
if (!function_exists('woocommerce_product_reviews_tab')) {
@ -637,7 +639,6 @@ if (!function_exists('woocommerce_output_related_products')) {
if (!function_exists('woocommerce_related_products')) {
function woocommerce_related_products( $posts_per_page = 4, $post_columns = 4, $orderby = 'rand' ) {
global $_product, $woocommerce_loop;
// Pass vars to loop