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
|
|
|
|
|
|
|
if( $product->get_price() === '' && $product->product_type!=='external') return;
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php if (!$product->is_in_stock()) : ?>
|
|
|
|
|
2012-02-17 21:08:56 +00:00
|
|
|
<a href="<?php echo 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
|
|
|
|
|
|
|
<?php
|
|
|
|
else :
|
|
|
|
|
|
|
|
switch ($product->product_type) :
|
|
|
|
case "variable" :
|
2012-02-17 21:08:56 +00:00
|
|
|
$link = get_permalink($product->id);
|
2012-01-05 11:31:22 +00:00
|
|
|
$label = apply_filters('variable_add_to_cart_text', __('Select options', 'woocommerce'));
|
2011-12-12 11:35:54 +00:00
|
|
|
break;
|
|
|
|
case "grouped" :
|
2012-02-17 21:08:56 +00:00
|
|
|
$link = get_permalink($product->id);
|
2012-01-05 11:31:22 +00:00
|
|
|
$label = apply_filters('grouped_add_to_cart_text', __('View options', 'woocommerce'));
|
2011-12-12 11:35:54 +00:00
|
|
|
break;
|
|
|
|
case "external" :
|
2012-02-17 21:08:56 +00:00
|
|
|
$link = get_permalink($product->id);
|
2012-01-05 11:31:22 +00:00
|
|
|
$label = apply_filters('external_add_to_cart_text', __('Read More', 'woocommerce'));
|
2011-12-12 11:35:54 +00:00
|
|
|
break;
|
|
|
|
default :
|
|
|
|
$link = esc_url( $product->add_to_cart_url() );
|
2012-01-05 11:31:22 +00:00
|
|
|
$label = apply_filters('add_to_cart_text', __('Add to cart', 'woocommerce'));
|
2011-12-12 11:35:54 +00:00
|
|
|
break;
|
|
|
|
endswitch;
|
|
|
|
|
|
|
|
echo sprintf('<a href="%s" data-product_id="%s" class="button add_to_cart_button product_type_%s">%s</a>', $link, $product->id, $product->product_type, $label);
|
|
|
|
|
|
|
|
endif;
|
|
|
|
?>
|