1条回答 默认 最新
- doudong3570 2018-11-24 22:57关注
Create
single.php
file in your active child theme (or active theme) in:woocommerce/single-product/add-to-cart/single.php
-
Change the code to:
<?php /** * Simple product add to cart * * This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php. * * HOWEVER, on occasion WooCommerce will need to update template files and you * (the theme developer) will need to copy the new files to your theme to * maintain compatibility. We try to do this as little as possible, but it does * happen. When this occurs the version of the template file will be bumped and * the readme will list any important changes. * * @see https://docs.woocommerce.com/document/template-structure/ * @package WooCommerce/Templates * @version 3.4.0 */ defined( 'ABSPATH' ) || exit; global $post; $short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt ); if ( ! $short_description ) { return; } global $product; if ( ! $product->is_purchasable() ) { return; } echo wc_get_stock_html( $product ); // WPCS: XSS ok. if ( $product->is_in_stock() ) : ?> <?php do_action( 'woocommerce_before_add_to_cart_form' ); ?> <form class="cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'> <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?> <?php do_action( 'woocommerce_before_add_to_cart_quantity' ); woocommerce_quantity_input( array( 'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ), 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ), 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok. ) ); do_action( 'woocommerce_after_add_to_cart_quantity' ); ?> <div class="woocommerce-product-details__short-description"> <?php echo $short_description; // WPCS: XSS ok. ?> </div> <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button> <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?> </form> <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?> <?php endif; ?>
-
Add this code to functions.php:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
解决 无用评论 打赏 举报
悬赏问题
- ¥20 @microsoft/fetch-event-source 流式响应问题
- ¥15 ogg dd trandata 报错
- ¥15 高缺失率数据如何选择填充方式
- ¥50 potsgresql15备份问题
- ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
- ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
- ¥60 pb数据库修改与连接
- ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
- ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
- ¥20 神经网络Sequential name=sequential, built=False