PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 2.1.3
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v2.1.3
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / app / src / Models / BuyLink.php
BuyLink.php
75 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace SureCart\Models;
3
4 /**
5 * Buy link model
6 */
7 class BuyLink {
8 /**
9 * Product model
10 *
11 * @var \SureCart\Models\Product
12 */
13 protected $product;
14
15 /**
16 * Constructor
17 *
18 * @param \SureCart\Models\Product $product Product model.
19 */
20 public function __construct( \SureCart\Models\Product $product ) {
21 $this->product = $product;
22 }
23
24 /**
25 * The buy page url.
26 *
27 * @return void
28 */
29 public function url() {
30 return trailingslashit( get_home_url() ) . trailingslashit( \SureCart::settings()->permalinks()->getBase( 'buy_page' ) ) . $this->product->slug;
31 }
32
33 /**
34 * Is the buy link enabled.
35 *
36 * @return boolean
37 */
38 public function isEnabled() {
39 return 'true' === ( $this->product->metadata->wp_buy_link_enabled ?? '' );
40 }
41
42 /**
43 * Get the mode.
44 *
45 * @return string
46 */
47 public function getMode() {
48 return 'true' === ( $this->product->metadata->wp_buy_link_test_mode_enabled ?? '' ) ? 'test' : 'live';
49 }
50
51 /**
52 * Should we show this item?
53 *
54 * @param string $item The name of the item.
55 *
56 * @return boolean
57 */
58 public function templatePartEnabled( $item ) {
59 switch ( $item ) {
60 case 'image':
61 return 'true' !== ( $this->product->metadata->wp_buy_link_product_image_disabled ?? '' );
62 case 'description':
63 return 'true' !== ( $this->product->metadata->wp_buy_link_product_description_disabled ?? '' );
64 case 'coupon':
65 return 'true' !== ( $this->product->metadata->wp_buy_link_coupon_field_disabled ?? '' );
66 case 'logo':
67 return 'true' !== ( $this->product->metadata->wp_buy_link_logo_disabled ?? '' );
68 case 'terms':
69 return 'true' !== ( $this->product->metadata->wp_buy_link_terms_disabled ?? '' );
70 }
71 return false;
72 }
73
74 }
75