Skip to content

Instantly share code, notes, and snippets.

@BurlesonBrad
Created April 13, 2015 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BurlesonBrad/0d023f814022184f6491 to your computer and use it in GitHub Desktop.
Save BurlesonBrad/0d023f814022184f6491 to your computer and use it in GitHub Desktop.
Modified quantity added to themes/theonepager-child/woocommerce/checkout/add-to-cart
<?php
/**
* Product quantity input
*
* Extends the WooCommerce quantity input template to include the add_to_cart data attribute.
*
* @package WooCommerce-One-Page-Checkout/Templates
* @version 1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
$input_button = woocommerce_quantity_input( array(
'input_name' => 'product_id',
'input_value' => ! empty( $product->cart_item['quantity'] ) ? $product->cart_item['quantity'] : 1,
'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity(),
'min_value' => 1,
), $product, false );
echo str_replace( 'type="number"', 'type="number" data-add_to_cart="' . $product->add_to_cart_id . '"', $input_button ); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment