woocommerce/templates/loop/add-to-cart.php

42 lines
1.2 KiB
PHP
Raw Normal View History

2011-12-12 11:35:54 +00:00
<?php
/**
* Loop Add to Cart
*/
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
<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
2012-05-26 14:18:29 +00:00
<?php else : ?>
<?php
switch ( $product->product_type ) {
case "variable" :
$link = get_permalink($product->id);
$label = apply_filters('variable_add_to_cart_text', __('Select options', 'woocommerce'));
break;
case "grouped" :
$link = get_permalink($product->id);
$label = apply_filters('grouped_add_to_cart_text', __('View options', 'woocommerce'));
break;
case "external" :
$link = get_permalink($product->id);
$label = apply_filters('external_add_to_cart_text', __('Read More', 'woocommerce'));
break;
default :
$link = esc_url( $product->add_to_cart_url() );
$label = apply_filters('add_to_cart_text', __('Add to cart', 'woocommerce'));
break;
}
printf('<a href="%s" rel="nofollow" data-product_id="%s" class="button add_to_cart_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; ?>