WC_Product_Simple

Simple Product Class.

Defined (1)

The class is defined in the following location(s).

/includes/class-wc-product-simple.php  
  1. class WC_Product_Simple extends WC_Product { 
  2.  
  3. /** 
  4. * Initialize simple product. 
  5. * @param mixed $product 
  6. */ 
  7. public function __construct( $product = 0 ) { 
  8. $this->supports[] = 'ajax_add_to_cart'; 
  9. parent::__construct( $product ); 
  10.  
  11. /** 
  12. * Get internal type. 
  13. * @return string 
  14. */ 
  15. public function get_type() { 
  16. return 'simple'; 
  17.  
  18. /** 
  19. * Get the add to url used mainly in loops. 
  20. * @return string 
  21. */ 
  22. public function add_to_cart_url() { 
  23. $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 ); 
  24.  
  25. return apply_filters( 'woocommerce_product_add_to_cart_url', $url, $this ); 
  26.  
  27. /** 
  28. * Get the add to cart button text. 
  29. * @return string 
  30. */ 
  31. public function add_to_cart_text() { 
  32. $text = $this->is_purchasable() && $this->is_in_stock() ? __( 'Add to cart', 'woocommerce' ) : __( 'Read more', 'woocommerce' ); 
  33.  
  34. return apply_filters( 'woocommerce_product_add_to_cart_text', $text, $this );