Advertisement
mattbailey

Jigoshop template hooks - Adjust markup on Products loop

Oct 25th, 2011
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. // Adjust markup on Products loop
  2.  
  3. remove_action( 'jigoshop_after_shop_loop_item', 'jigoshop_template_loop_add_to_cart', 10, 2);
  4.  
  5. function jigoshop_template_loop_add_to_cart_new( $post, $_product ) {
  6.    
  7.     // do not show "add to cart" button if product's price isn't announced
  8.     if( $_product->get_price() === '' AND ! ($_product->is_type('variable') OR $_product->is_type('grouped')) ) return;
  9.    
  10.     // TODO: this could use refactoring / cleaning up
  11.     if( $_product->is_type('variable') OR $_product->is_type('grouped') ) {
  12.         echo '<a href="'. get_permalink($_product->id).'" class="button">'.__('Shop now', 'jigoshop').'</a>';
  13.         return;
  14.     }
  15.    
  16.     ?><a href="<?php echo $_product->add_to_cart_url(); ?>" class="button"><?php _e('Add to cart', 'jigoshop'); ?></a><?php
  17. }
  18.  
  19. add_action( 'jigoshop_after_shop_loop_item', 'jigoshop_template_loop_add_to_cart_new', 10, 2);
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement