0
votes

I have a button that I've added to my product page, and I want to query the quantity in the woocommerce_quantity_input() control. For the life of me I can't find how to do that. I can get $product information, and $cart information, but I can't find how to get the quantity that is on this page (before I add it to the cart).

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

global $woocommerce;
?>

<div class="calculateshipping-button-container" 
    style="display:block;float:<?php echo $button_align_default; ?>;">

    <div class="calculateshipping-button">
        <div class="cs-btn" data-layout="button_count" 
            data-width="<?php echo $option_csbtn_width; ?>" data-show-faces="false">

            <button type="button"  class="shipping-calculator-button button"   
                id="showHideForm"><?php _e('Calculate Shipping', $this->app_name );?>
            </button>
        </div>
     </div>
</div>
<?php 
global $product;
global $quantity;

if(isset($_POST['calc_shipping']) && $_POST['calc_shipping'] == '1')
{

so I want to get the quantity next to the "Add To Cart Button"

and is added to the page with:

<?php do_action( 'woocommerce_before_shipping_calculator' ); ?>

<form class="shipping_calculator" action="" method="post">

with the "Calculate Button" defined as

<p><button type="submit" name="calc_shipping" value="1"    class="button_shipping">
<?php _e( 'Calculate', 'woocommerce' ); ?></button></p>
1
Can you elaborate no what you are trying to do? Or use a screenshot? I don't understand what you are asking.helgatheviking
Yep.. so I have a button on my product page. When pressed, I want to query the current count that is in the quanity_input() next to Add to Cart. I don't want it to add it to the count, I just need that value in a message I need to display. I do calculations based on the $product, however I can't find where to get the quantity currenly displayed on the page.justdan0227
Can you show your code? (Edit the question as code is borderline illegible in the comments). The typical quantity input has a class of qty for selection via jquery or a name of quantity which then is available as a key in the $_POST data.helgatheviking
Updated the post. Any thoughts?justdan0227

1 Answers

0
votes

Well I had to add an ajax function to the input field that would then update a hidden field in my form. Then when the Calculate button is pressed, I have access to the updated quantity.