PHP syntax within HTML - Add To Cart Button
<p>I am trying to parse and return the ID of a product within woocommerce using <code>&lt;?php echo $product-&gt;id; ?&gt;</code> on line 6, however I am having issues understanding the syntax within the function.</p>

<pre><code>add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );
    function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {
      if ( $product &amp;&amp; $product-&gt;is_type( 'simple' ) &amp;&amp; $product-&gt;is_purchasable() &amp;&amp; $product-&gt;is_in_stock() &amp;&amp; ! $product-&gt;is_sold_individually() ) {
        $html = '&lt;form action="' . esc_url( $product-&gt;add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data"&gt;';
        $html .= woocommerce_quantity_input( array(), $product, false );
        $html .= '&lt;button type="submit" data-quantity="1" data-product_id="&lt;?php echo $product-&gt;id; ?&gt;" class="button alt ajax_add_to_cart add_to_cart_button product_type_simple qodef-btn qodef-btn-outline"&gt;Add&lt;/button&gt;';
        $html .= '&lt;/form&gt;';
      }
      return $html;
    }
</code></pre>

<p>This unfortunately just spits out <code>data-product_id="&lt;?php echo $product-&gt;id; ?&gt;"</code> as the output html. I would like it to return the product ID which is a number so that AJAX can take care of the add to cart process.</p>

<p>I am fine to do legwork I am just stuck on what I am actually dealing with!</p>

<p>Thanks Kindly.</p>

<p><strong>EDIT - Final Solution</strong></p>

<p>Thanks to <strong><em>krlv</em></strong></p>

<p>On the off chance anyone wants the function and js to add quantity buttons (minus, input, plus next to the add to cart button) to the products in the product gallery (archive) in woocommerce;</p>

<p>PHP for functions.php</p>

<pre><code>add_filter( 'woocommerce_loop_add_to_cart_link', 
'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );

function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {
  if ( $product &amp;&amp; $product-&gt;is_type( 'simple' ) &amp;&amp; $product-&gt;is_purchasable() &amp;&amp; $product-&gt;is_in_stock() &amp;&amp; ! $product-&gt;is_sold_individually() ) {
    $html = '&lt;form action="' . esc_url( $product-&gt;add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data"&gt;';
    $html .= woocommerce_quantity_input( array(), $product, false );
    $html .= '&lt;button type="submit" data-quantity="1" data-product_id="' .  $product-&gt;id . '" class="button alt ajax_add_to_cart add_to_cart_button product_type_simple Add_Your_Style_Classes_Here"&gt;Add&lt;/button&gt;';

    $html .= '&lt;/form&gt;';
  }
  return $html;
}
</code></pre>

<p>JS </p>

<pre><code>jQuery(function($) {

$("form.cart").on("change", "input.qty", function() {
    $(this.form).find("button[data-quantity]").data("quantity", this.value);
});
$(document.body).on("adding_to_cart", function() {
    $("a.added_to_cart").remove();
});

});
</code></pre>