<?php

namespace POPxPMPro\Providers;

defined( 'ABSPATH' ) || die( 'Not allowed.' );

class Product extends \WcElectronInvoice\Providers\ProductAbstract {

	/**
	 * @var \PMPro_Membership_Level
	 */
	protected $product;


	function get_id() {
		return ( is_object( $this->product ) && isset( $this->product->level_id ) )
			? $this->product->level_id
			: 0;
	}

	function get_sku() {
		$product = $this->product;

		// Some PMPro custom orders do not have a membership level.
		if ( ! is_object( $product ) || ! isset( $product->level_id ) ) {
			return '';
		}

		$level_id = (int) $product->level_id;
		if ( 0 >= $level_id ) {
			return '';
		}

		$name = isset( $product->name ) ? $product->name : '';

		return \WcElectronInvoice\Functions\strtoupper( $level_id . '-' . sanitize_title( $name ) );
	}


	function get_tax_class() {
		return '';
	}

	public function get_tax_status() {
		return 'taxable';
	}

	function get_name() {
		return is_object( $this->product ) && isset( $this->product->name ) ? $this->product->name : '';
	}

	function get_short_description() {
		return is_object( $this->product ) && isset( $this->product->description ) ? $this->product->description : '';
	}

	function get_description() {
		return $this->get_short_description();
	}
}
