<?php
/**
 * Product Schema Type
 *
 * @package SEOvaultSEO\Schema\Types
 */

namespace SEOvaultSEO\Schema\Types;

use SEOvaultSEO\Schema\SchemaBase;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class Product extends SchemaBase {

	public function schema_data() {
		return array(
			'title'   => 'Product',
			'type'    => 'Product',
			'show_on' => array(
				'rules'        => array( 'post|product' ),
				'specific'     => array(),
				'specificText' => array(),
			),
			'fields'  => $this->parse_fields( $this->get() ),
		);
	}

	public function get() {
		return apply_filters(
			'seovaultseo_schema_type_product',
			array(
				array(
					'id'      => 'schema_name',
					'label'   => __( 'Schema Title', 'seovault-ai' ),
					'show'    => true,
					'default' => true,
					'type'    => 'Title',
					'std'     => 'Product',
				),
				array(
					'id'       => '@id',
					'type'     => 'Hidden',
					'std'      => '%current.url%#product',
					'required' => true,
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'       => 'name',
					'label'    => __( 'Product Name', 'seovault-ai' ),
					'required' => true,
					'std'      => '%post.title%',
					'type'     => 'Text',
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'      => 'description',
					'label'   => __( 'Description', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '%wc_shortdesc%',
					'type'    => 'Text',
				),
				array(
					'id'       => 'url',
					'label'    => __( 'URL', 'seovault-ai' ),
					'required' => true,
					'std'      => '%post.url%',
					'type'     => 'Text',
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'      => 'sku',
					'label'   => __( 'SKU', 'seovault-ai' ),
					'std'     => '%wc_sku%',
					'type'    => 'Text',
					'default' => true,
					'show'    => true,
				),
				array(
					'id'      => 'brand',
					'label'   => __( 'Brand', 'seovault-ai' ),
					'std'     => '%wc_brand%',
					'type'    => 'Text',
					'default' => true,
					'show'    => true,
				),
				array(
					'id'      => 'image',
					'label'   => __( 'Image', 'seovault-ai' ),
					'std'     => '%post.thumbnail%',
					'type'    => 'Image',
					'default' => true,
					'show'    => true,
				),
				array(
					'id'      => 'offers',
					'label'   => __( 'Offers', 'seovault-ai' ),
					'type'    => 'Group',
					'default' => true,
					'show'    => true,
					'fields'  => array(
						array(
							'id'      => '@type',
							'type'    => 'Hidden',
							'std'     => 'Offer',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'price',
							'label'   => __( 'Price', 'seovault-ai' ),
							'std'     => '%wc_price%',
							'type'    => 'Text',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'priceCurrency',
							'label'   => __( 'Currency', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Text',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'availability',
							'label'   => __( 'Availability', 'seovault-ai' ),
							'std'     => 'https://schema.org/InStock',
							'type'    => 'Text',
							'default' => true,
							'show'    => true,
						),
					),
				),
			)
		);
	}
}
