external.php
2 years ago
grouped.php
2 years ago
simple.php
2 years ago
variable.php
1 year ago
variation-add-to-cart-button.php
2 years ago
variation.php
1 year ago
simple.php
57 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Simple product add to cart |
| 4 | * |
| 5 | * This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php. |
| 6 | * |
| 7 | * HOWEVER, on occasion WooCommerce will need to update template files and you |
| 8 | * (the theme developer) will need to copy the new files to your theme to |
| 9 | * maintain compatibility. We try to do this as little as possible, but it does |
| 10 | * happen. When this occurs the version of the template file will be bumped and |
| 11 | * the readme will list any important changes. |
| 12 | * |
| 13 | * @see https://woocommerce.com/document/template-structure/ |
| 14 | * @package WooCommerce\Templates |
| 15 | * @version 7.0.1 |
| 16 | */ |
| 17 | |
| 18 | defined( 'ABSPATH' ) || exit; |
| 19 | |
| 20 | global $product; |
| 21 | |
| 22 | if ( ! $product->is_purchasable() ) { |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | echo wc_get_stock_html( $product ); // WPCS: XSS ok. |
| 27 | |
| 28 | if ( $product->is_in_stock() ) : ?> |
| 29 | |
| 30 | <?php do_action( 'woocommerce_before_add_to_cart_form' ); ?> |
| 31 | |
| 32 | <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'> |
| 33 | <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?> |
| 34 | |
| 35 | <?php |
| 36 | do_action( 'woocommerce_before_add_to_cart_quantity' ); |
| 37 | |
| 38 | woocommerce_quantity_input( |
| 39 | array( |
| 40 | 'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ), |
| 41 | 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ), |
| 42 | 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok. |
| 43 | ) |
| 44 | ); |
| 45 | |
| 46 | do_action( 'woocommerce_after_add_to_cart_quantity' ); |
| 47 | ?> |
| 48 | |
| 49 | <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_attr( wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '' ); ?>"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button> |
| 50 | |
| 51 | <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?> |
| 52 | </form> |
| 53 | |
| 54 | <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?> |
| 55 | |
| 56 | <?php endif; ?> |
| 57 |