HEX
Server: Apache
System: Linux ecngx285.inmotionhosting.com 4.18.0-553.79.1.lve.el8.x86_64 #1 SMP Wed Oct 15 17:59:35 UTC 2025 x86_64
User: zeusxp5 (3862)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /home/zeusxp5/tour.kamille.us/wp-content/plugins/surecart/app/src/Models/BuyLink.php
<?php
namespace SureCart\Models;

/**
 * Buy link model
 */
class BuyLink {
	/**
	 * Product model
	 *
	 * @var \SureCart\Models\Product
	 */
	protected $product;

	/**
	 * Constructor
	 *
	 * @param \SureCart\Models\Product $product Product model.
	 */
	public function __construct( \SureCart\Models\Product $product ) {
		$this->product = $product;
	}

	/**
	 * The buy page url.
	 *
	 * @return void
	 */
	public function url() {
		return trailingslashit( get_home_url() ) . trailingslashit( \SureCart::settings()->permalinks()->getBase( 'buy_page' ) ) . $this->product->slug;
	}

	/**
	 * Is the buy link enabled.
	 *
	 * @return boolean
	 */
	public function isEnabled() {
		return 'true' === ( $this->product->metadata->wp_buy_link_enabled ?? '' );
	}

	/**
	 * Get the mode.
	 *
	 * @return string
	 */
	public function getMode() {
		return 'true' === ( $this->product->metadata->wp_buy_link_test_mode_enabled ?? '' ) ? 'test' : 'live';
	}

	/**
	 * Get the success url.
	 *
	 * @return string
	 */
	public function getSuccessUrl() {
		if ( 'true' !== ( $this->product->metadata->wp_buy_link_success_page_enabled ?? '' ) ) {
			return '';
		}
		return $this->product->metadata->wp_buy_link_success_page_url ?? '';
	}

	/**
	 * Should we show this item?
	 *
	 * @param string $item The name of the item.
	 *
	 * @return boolean
	 */
	public function templatePartEnabled( $item ) {
		switch ( $item ) {
			case 'image':
				return 'true' !== ( $this->product->metadata->wp_buy_link_product_image_disabled ?? '' );
			case 'description':
				return 'true' !== ( $this->product->metadata->wp_buy_link_product_description_disabled ?? '' );
			case 'coupon':
				return 'true' !== ( $this->product->metadata->wp_buy_link_coupon_field_disabled ?? '' );
			case 'logo':
				return 'true' !== ( $this->product->metadata->wp_buy_link_logo_disabled ?? '' );
			case 'terms':
				return 'true' !== ( $this->product->metadata->wp_buy_link_terms_disabled ?? '' );
		}
		return false;
	}

}