<?php
/**
 * Backward compatibility with "Woocommerce" WordPress plugin.
 *
 * @see https://wordpress.org/plugins/woocommerce
 *
 * @since 4.4 vendors initialization moved to hooks in autoload/vendors.
 */

if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

return [
	'vc_gitem_wocommerce' => [
		'name' => esc_html__( 'WooCommerce field', 'js_composer' ),
		'base' => 'vc_gitem_wocommerce',
		'icon' => 'icon-wpb-woocommerce',
		'category' => esc_html__( 'Content', 'js_composer' ),
		'description' => esc_html__( 'Woocommerce', 'js_composer' ),
		'php_class_name' => 'Vc_Gitem_Woocommerce_Shortcode',
		'params' => [
			[
				'type' => 'dropdown',
				'heading' => esc_html__( 'Content type', 'js_composer' ),
				'param_name' => 'post_type',
				'value' => [
					esc_html__( 'Product', 'js_composer' ) => 'product',
					esc_html__( 'Order', 'js_composer' ) => 'order',
				],
				'save_always' => true,
				'description' => esc_html__( 'Select Woo Commerce post type.', 'js_composer' ),
				'edit_field_class' => 'vc_col-xs-6',
			],
			[
				'type' => 'dropdown',
				'heading' => esc_html__( 'Product field', 'js_composer' ),
				'param_name' => 'product_field_key',
				'value' => Vc_Vendor_Woocommerce::getProductsFieldsList(),
				'dependency' => [
					'element' => 'post_type',
					'value' => [ 'product' ],
				],
				'save_always' => true,
				'description' => esc_html__( 'Choose field from product.', 'js_composer' ),
				'edit_field_class' => 'vc_col-xs-6',
			],
			[
				'type' => 'textfield',
				'heading' => esc_html__( 'Product custom key', 'js_composer' ),
				'param_name' => 'product_custom_key',
				'description' => esc_html__( 'Enter custom key.', 'js_composer' ),
				'dependency' => [
					'element' => 'product_field_key',
					'value' => [ '_custom_' ],
				],
			],
			[
				'type' => 'dropdown',
				'heading' => esc_html__( 'Order fields', 'js_composer' ),
				'param_name' => 'order_field_key',
				'value' => Vc_Vendor_Woocommerce::getOrderFieldsList(),
				'dependency' => [
					'element' => 'post_type',
					'value' => [ 'order' ],
				],
				'save_always' => true,
				'description' => esc_html__( 'Choose field from order.', 'js_composer' ),
				'edit_field_class' => 'vc_col-xs-6',
			],
			[
				'type' => 'textfield',
				'heading' => esc_html__( 'Order custom key', 'js_composer' ),
				'param_name' => 'order_custom_key',
				'dependency' => [
					'element' => 'order_field_key',
					'value' => [ '_custom_' ],
				],
				'description' => esc_html__( 'Enter custom key.', 'js_composer' ),
			],
			[
				'type' => 'toggle',
				'heading' => esc_html__( 'Show label', 'js_composer' ),
				'param_name' => 'show_label',
				'value' => [ esc_html__( 'Yes', 'js_composer' ) => 'yes' ],
				'std' => '',
				'save_always' => true,
				'description' => esc_html__( 'Enter label to display before key value.', 'js_composer' ),
			],
			[
				'type' => 'button_group',
				'heading' => esc_html__( 'Alignment', 'js_composer' ),
				'param_name' => 'align',
				'value' => vc_config()->get_text_align_param_value(),
				'std' => 'left',
				'save_always' => true,
				'description' => esc_html__( 'Select alignment.', 'js_composer' ),
			],
			vc_config()->get_extra_class_params(),
		],
		'post_type' => Vc_Grid_Item_Editor::postType(),
		'sections' => vc_config()->get_advanced_sections(),
	],
];
