如何在Woocommerce数量字段中删除class =“ quantity”

时间:2019-08-13 06:18:25

标签: php wordpress woocommerce

如何在woocommerce_quantity_input(Woocommerce)中删除<div class="quantity">

$quantity=woocommerce_quantity_input();

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

2 个答案:

答案 0 :(得分:0)

您可以为此使用preg_replace

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];

小提琴 PHPFiddle

答案 1 :(得分:0)

如果要覆盖woocommerce插件文件,请从global / quantity-input.php中删除类数量