2011-12-12 11:35:54 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Loop Add to Cart
|
|
|
|
*/
|
|
|
|
|
2012-02-17 21:08:56 +00:00
|
|
|
global $product;
|
2011-12-12 11:35:54 +00:00
|
|
|
|
2012-05-26 14:18:29 +00:00
|
|
|
if( $product->get_price() === '' && $product->product_type != 'external' ) return;
|
2011-12-12 11:35:54 +00:00
|
|
|
?>
|
|
|
|
|
2012-05-26 14:18:29 +00:00
|
|
|
<?php if ( ! $product->is_in_stock() ) : ?>
|
2011-12-12 11:35:54 +00:00
|
|
|
|
2012-07-10 14:39:51 +00:00
|
|
|
<a href="<?php echo apply_filters( 'out_of_stock_add_to_cart_url', get_permalink( $product->id ) ); ?>" class="button"><?php echo apply_filters( 'out_of_stock_add_to_cart_text', __( 'Read More', 'woocommerce' ) ); ?></a>
|
2011-12-12 11:35:54 +00:00
|
|
|
|
2012-05-26 14:18:29 +00:00
|
|
|
<?php else : ?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
switch ( $product->product_type ) {
|
|
|
|
case "variable" :
|
2012-07-10 14:39:51 +00:00
|
|
|
$link = apply_filters( 'variable_add_to_cart_url', get_permalink( $product->id ) );
|
|
|
|
$label = apply_filters( 'variable_add_to_cart_text', __('Select options', 'woocommerce') );
|
2012-05-26 14:18:29 +00:00
|
|
|
break;
|
|
|
|
case "grouped" :
|
2012-07-10 14:39:51 +00:00
|
|
|
$link = apply_filters( 'grouped_add_to_cart_url', get_permalink( $product->id ) );
|
|
|
|
$label = apply_filters( 'grouped_add_to_cart_text', __('View options', 'woocommerce') );
|
2012-05-26 14:18:29 +00:00
|
|
|
break;
|
|
|
|
case "external" :
|
2012-07-10 14:39:51 +00:00
|
|
|
$link = apply_filters( 'external_add_to_cart_url', get_permalink( $product->id ) );
|
|
|
|
$label = apply_filters( 'external_add_to_cart_text', __('Read More', 'woocommerce') );
|
2012-05-26 14:18:29 +00:00
|
|
|
break;
|
|
|
|
default :
|
2012-07-10 14:39:51 +00:00
|
|
|
$link = apply_filters( 'add_to_cart_url', esc_url( $product->add_to_cart_url() ) );
|
|
|
|
$label = apply_filters( 'add_to_cart_text', __('Add to cart', 'woocommerce') );
|
2012-05-26 14:18:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-07-30 15:01:33 +00:00
|
|
|
printf('<a href="%s" rel="nofollow" data-product_id="%s" class="add_to_cart_button button product_type_%s">%s</a>', $link, $product->id, $product->product_type, $label);
|
2011-12-12 11:35:54 +00:00
|
|
|
|
2012-05-26 14:18:29 +00:00
|
|
|
?>
|
2011-12-12 11:35:54 +00:00
|
|
|
|
2012-05-26 14:18:29 +00:00
|
|
|
<?php endif; ?>
|