在 WooCommerce 的输入类型名称中显示 PHP getter 值
Show PHP getter value in input type name in WooCommerce
我想在从 getters 获取后以输入类型显示产品值:
代码:
$domain = 'woocommerce';
global $product;
// Getters
$price = $product->get_price();
$currency_symbol = get_woocommerce_currency_symbol();
printf( '<label>%s</label><input name="price" value="$price" required="true" type="number"/><br>', __( 'Fixed price:', $domain ) );
printf( '<label>%s</label><input name="price" value="%.02f" required="true" type="number"/><br>', __( 'Fixed price:', $domain ), $price );
将浮点值作为 %f 占位符
传递给 printf()
函数
我想在从 getters 获取后以输入类型显示产品值:
代码:
$domain = 'woocommerce';
global $product;
// Getters
$price = $product->get_price();
$currency_symbol = get_woocommerce_currency_symbol();
printf( '<label>%s</label><input name="price" value="$price" required="true" type="number"/><br>', __( 'Fixed price:', $domain ) );
printf( '<label>%s</label><input name="price" value="%.02f" required="true" type="number"/><br>', __( 'Fixed price:', $domain ), $price );
将浮点值作为 %f 占位符
传递给printf()
函数