暂无描述

add-to-cart.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Loop Add to Cart
  4. *
  5. * This template can be overridden by copying it to yourtheme/woocommerce/loop/add-to-cart.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. * @package WooCommerce\Templates
  15. * @version 3.3.0
  16. */
  17. if ( ! defined( 'ABSPATH' ) ) {
  18. exit;
  19. }
  20. global $product;
  21. echo apply_filters(
  22. 'woocommerce_loop_add_to_cart_link', // WPCS: XSS ok.
  23. sprintf(
  24. '<a href="%s" data-quantity="%s" class="%s" %s>%s</a>',
  25. esc_url( $product->add_to_cart_url() ),
  26. esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
  27. esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ),
  28. isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
  29. esc_html( $product->add_to_cart_text() )
  30. ),
  31. $product,
  32. $args
  33. );