/templates/single-product/add-to-cart/simple.php

  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://docs.woocommerce.com/document/template-structure/ 
  14. * @author WooThemes 
  15. * @package WooCommerce/Templates 
  16. * @version 3.0.0 
  17. */ 
  18. if ( ! defined( 'ABSPATH' ) ) { 
  19. exit; 
  20.  
  21. global $product; 
  22.  
  23. if ( ! $product->is_purchasable() ) { 
  24. return; 
  25.  
  26. echo wc_get_stock_html( $product ); 
  27.  
  28. if ( $product->is_in_stock() ) : ?> 
  29.  
  30. <?php do_action( 'woocommerce_before_add_to_cart_form' ); ?> 
  31.  
  32. <form class="cart" method="post" enctype='multipart/form-data'> 
  33. <?php 
  34. /** 
  35. * @since 2.1.0. 
  36. */ 
  37. do_action( 'woocommerce_before_add_to_cart_button' ); 
  38.  
  39. /** 
  40. * @since 3.0.0. 
  41. */ 
  42. do_action( 'woocommerce_before_add_to_cart_quantity' ); 
  43.  
  44. woocommerce_quantity_input( array( 
  45. 'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ),  
  46. 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ),  
  47. 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( $_POST['quantity'] ) : $product->get_min_purchase_quantity(),  
  48. ) ); 
  49.  
  50. /** 
  51. * @since 3.0.0. 
  52. */ 
  53. do_action( 'woocommerce_after_add_to_cart_quantity' ); 
  54. ?> 
  55.  
  56. <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> 
  57.  
  58. <?php 
  59. /** 
  60. * @since 2.1.0. 
  61. */ 
  62. do_action( 'woocommerce_after_add_to_cart_button' ); 
  63. ?> 
  64. </form> 
  65.  
  66. <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?> 
  67.  
  68. <?php endif; ?> 
.