Hi there,
You can override quantity-input.php into your theme. Read this helpful information.
Then replace the default code with this one.
<div class="quantity">
<?php
// Your predefined prices
$predefined_prices = array(100, 250, 500);
?>
<select step="<?php echo esc_attr( $step ); ?>" <?php if ( is_numeric( $min_value ) ) : ?>min="<?php echo esc_attr( $min_value ); ?>"<?php endif; ?> <?php if ( is_numeric( $max_value ) ) : ?>max="<?php echo esc_attr( $max_value ); ?>"<?php endif; ?> name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" title="<?php _ex( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>">
<?php
foreach($predefined_prices as $price){
echo '<option value="'.esc_attr($price).'" '.selected( $price, esc_attr( $input_value ) ).'>'.esc_attr($price).'</option>';
}
?>
</select>
</div>
I’ve tested on my end. It works.
Let me know how it works for you.
Hello, I am trying to do something very similar, to have a drop down of quantities in my cart. However, I created an attribute for my quantities for a variable product, and each quantity has a different price that I set in my variations. Is there a way to have the cart to show the quantity-price variation the way I have it on the product page?
I currently have the quantity input field hidden on my product page since I have it set up as an attribute.