WooCommerce加号和减号按钮 [英] WooCommerce plus and minus buttons
问题描述
我是一名Web开发人员,我想与WooCommerce建立自己的网上商店.但是我有一个问题产品页面上的加号和减号按钮没有显示,有人知道如何获得这些按钮(也许在某处添加一些代码)吗?
I am a Web Developer and I want to make my own webshop with WooCommerce. But I have a problem, The plus and minus buttons on the product page are not showing, do anyone know how to get these buttons (maybe to add some code somewhere)?
推荐答案
您需要在子主题中覆盖woocommerce中的数量输入".这位于插件-> woocommerce->模板->全局->数量输入复制此文件中的内容.在主题文件夹中,创建"woocommerce"目录.在此目录中创建另一个名为"global"的文件夹.将内容粘贴到这里.
You need to override the 'quantity-input' from woocommerce in your child theme. This is located in plugins -> woocommerce -> templates -> global -> quantity-input Copy the contents from this file.In your theme folder create a 'woocommerce' directory. Create another folder named 'global' in this directory. Paste the contents over here.
找到代码
<input type="number" step="<?php echo esc_attr( $step ); ?>" <?php if ( is_numeric( $min_value ) ) : ?>min="<?php echo esc_attr( $min_value ); ?>"<?php endif; ?> <?php if ( is_numeric( $max_value ) ) : ?>max="<?php echo esc_attr( $max_value ); ?>"<?php endif; ?> name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" title="<?php _ex( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" class="input-text qty text" size="4" />
在此之上在其上方添加这段代码
Above this add this piece of code above it
<input class="minus" type="button" value="-">
和它下面的那一块
<input class="plus" type="button" value="+">
您的总体代码如下:
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
<div class="quantity">
<input class="minus" type="button" value="-">
<input type="number" step="<?php echo esc_attr( $step ); ?>" <?php if ( is_numeric( $min_value ) ) : ?>min="<?php echo esc_attr( $min_value ); ?>"<?php endif; ?> <?php if ( is_numeric( $max_value ) ) : ?>max="<?php echo esc_attr( $max_value ); ?>"<?php endif; ?> name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" title="<?php _ex( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" class="input-text qty text" size="4" />
<input class="plus" type="button" value="+">
</div>
这篇关于WooCommerce加号和减号按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!