<?php

namespace Unlockafe_addons\Classes;

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}

/**
 * Class Product_Gift_Card
 *
 * @package Unlockafe_addons\Classes
 */
class Product_Gift_Card extends \WC_Product_Simple {

    /**
     * Get internal type.
     *
     * @return string
     */
    public function get_type() {
        return 'unlockafe_gift_card';
    }

    /**
     * We are a virtual product.
     *
     * @param string $context
     * @return bool
     */
    public function is_virtual($context = 'view') {
        return true;
    }

    /**
     * We are not a sold individually product.
     *
     * @param string $context
     * @return bool
     */
    public function is_sold_individually($context = 'view') {
        return false;
    }

    /**
     * Get the price of the gift card.
     *
     * If the gift card has a custom amount, the price will be determined by the user.
     * Otherwise, it falls back to the regular price.
     *
     * @param string $context
     * @return string
     */
    public function get_price($context = 'view') {
        $price = $this->get_prop('regular_price', $context);
        if ($this->get_meta('_unlockafe_gift_card_type') === 'custom') {
            $price = ''; // Price will be set by the user on the frontend.
        }
        return $price;
    }
}
