2012-11-22 10:22:18 +00:00
|
|
|
<?php
|
2013-02-20 17:14:46 +00:00
|
|
|
|
2014-09-20 18:57:32 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit; // Exit if accessed directly
|
|
|
|
}
|
2013-02-20 17:14:46 +00:00
|
|
|
|
2012-11-22 10:22:18 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Simple Product Class.
|
2012-11-22 10:22:18 +00:00
|
|
|
*
|
2012-11-29 16:48:40 +00:00
|
|
|
* The default product type kinda product.
|
2012-11-22 10:22:18 +00:00
|
|
|
*
|
|
|
|
* @class WC_Product_Simple
|
|
|
|
* @package WooCommerce/Classes/Products
|
2013-02-20 17:14:46 +00:00
|
|
|
* @category Class
|
2012-11-22 10:22:18 +00:00
|
|
|
* @author WooThemes
|
|
|
|
*/
|
|
|
|
class WC_Product_Simple extends WC_Product {
|
|
|
|
|
|
|
|
/**
|
2015-07-16 19:55:48 +00:00
|
|
|
* Initialize simple product.
|
2012-11-27 16:22:47 +00:00
|
|
|
*
|
2012-11-22 10:22:18 +00:00
|
|
|
* @param mixed $product
|
|
|
|
*/
|
2016-10-25 20:24:27 +00:00
|
|
|
public function __construct( $product = 0 ) {
|
2015-11-02 11:23:50 +00:00
|
|
|
$this->supports[] = 'ajax_add_to_cart';
|
2012-11-22 10:22:18 +00:00
|
|
|
parent::__construct( $product );
|
|
|
|
}
|
2012-11-29 16:48:40 +00:00
|
|
|
|
2016-10-17 11:22:23 +00:00
|
|
|
/**
|
|
|
|
* Get internal type.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function get_type() {
|
|
|
|
return 'simple';
|
|
|
|
}
|
|
|
|
|
2013-09-25 11:35:06 +00:00
|
|
|
/**
|
|
|
|
* 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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Get the add to cart button text.
|
2013-09-25 11:35:06 +00:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function add_to_cart_text() {
|
2016-06-30 18:16:26 +00:00
|
|
|
$text = $this->is_purchasable() && $this->is_in_stock() ? __( 'Add to cart', 'woocommerce' ) : __( 'Read more', 'woocommerce' );
|
2013-09-25 11:35:06 +00:00
|
|
|
|
|
|
|
return apply_filters( 'woocommerce_product_add_to_cart_text', $text, $this );
|
|
|
|
}
|
2014-09-20 18:57:32 +00:00
|
|
|
}
|