Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

Center quantity box and add to cart button on Category pages

Home / Forums / Virtue Theme / Center quantity box and add to cart button on Category pages

This topic is: Resolved
[Resolved]
Posted in: Virtue Theme
July 17, 2015 at 12:23 pm

I’ve turned on the “Add to Cart” under woocommerce–> Products–> Display

and I’ve changed add-to-cart-.php to give me the QTY +/- button

<?php
/**
* Loop Add to Cart
*/
global $product;

if( $product->get_price() === '' && $product->product_type != 'external' ) return;
?>
<?php if ( ! $product->is_in_stock() ) : ?>
id); ?>" class="button"><?php echo apply_filters('out_of_stock_add_to_cart_text', __('Read More', 'woocommerce')); ?>
<?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('%s', $link, $product->id, $product->product_type, $label);
if ( $product->product_type == 'simple' ) {
?>
<form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>" class="cart" method="post" enctype='multipart/form-data'>
<?php woocommerce_quantity_input(); ?>
<button type="submit" class="button alt"><?php echo $label; ?></button>
</form>
<?php
} else {
printf('%s', $link, $product->id, $product->product_type, $label);
}
?>
<?php endif; ?>

How can I get these buttons to be centered on Product Category pages but keep it aligned left (as is the default) on single product pages?

Here’s a page with the issue:

Thanks.

  • The forum ‘Virtue Theme’ is closed to new topics and replies.