skip to Main Content

How to remove <div class="quantity"> in woocommerce_quantity_input (Woocommerce)

$quantity=woocommerce_quantity_input();

$quantity_field= str_replace('<div class="quantity">', '', $quantity);

2

Answers


  1. You can use preg_replace for this!

    preg_match('/^(<div class="quantity">)(.*?)(</div>)$/', woocommerce_quantity_input(), $matches);
    
    // this will output whatever is in the middle of <div class="quantity"></div>
    $quantity_field = $matches[2];
    

    Fiddle: PHPFiddle

    Login or Signup to reply.
  2. If you are overiding woocommerce plugin files, remove class quantity from global/quantity-input.php

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search