| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- /**
- * Simple Product Class.
- *
- * The default product type kinda product.
- *
- * @package WooCommerce/Classes/Products
- */
- defined( 'ABSPATH' ) || exit;
- /**
- * Simple product class.
- */
- class WC_Product_Simple extends WC_Product {
- /**
- * Initialize simple product.
- *
- * @param WC_Product|int $product Product instance or ID.
- */
- public function __construct( $product = 0 ) {
- $this->supports[] = 'ajax_add_to_cart';
- parent::__construct( $product );
- }
- /**
- * Get internal type.
- *
- * @return string
- */
- public function get_type() {
- return 'simple';
- }
- /**
- * Get the add to url used mainly in loops.
- *
- * @return string
- */
- public function add_to_cart_url() {
- $url = $this->is_purchasable() && $this->is_in_stock() ? remove_query_arg( 'added-to-cart', add_query_arg( 'add-to-cart', $this->id ) ) : get_permalink( $this->id );
- return apply_filters( 'woocommerce_product_add_to_cart_url', $url, $this );
- }
- /**
- * Get the add to cart button text.
- *
- * @return string
- */
- public function add_to_cart_text() {
- $text = $this->is_purchasable() && $this->is_in_stock() ? __( 'Add to cart', 'woocommerce' ) : __( 'Read more', 'woocommerce' );
- return apply_filters( 'woocommerce_product_add_to_cart_text', $text, $this );
- }
- /**
- * Get the add to cart button text description - used in aria tags.
- *
- * @since 3.3.0
- * @return string
- */
- public function add_to_cart_description() {
- /* translators: %s: Product title */
- $text = $this->is_purchasable() && $this->is_in_stock() ? __( 'Add “%s” to your cart', 'woocommerce' ) : __( 'Read more about “%s”', 'woocommerce' );
- return apply_filters( 'woocommerce_product_add_to_cart_description', sprintf( $text, $this->get_name() ), $this );
- }
- }
|