<?php
/**
 * Widget Name: Cart Page
 * Description: Renders the WooCommerce cart via the [woocommerce_cart] shortcode
 *              with styling controls for the cart table, quantity field, coupon,
 *              action buttons, the proceed-to-checkout button and cart totals.
 *              Ships with multiple visual styles.
 *
 * @package    captain-widgets-kit
 * @subpackage captain-widgets-kit/includes
 * @since      1.2.0
 */

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

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Background;

/**
 * Class Captwiki_Woo_Cart
 *
 * @since 1.2.0
 */
class Captwiki_Woo_Cart extends Widget_Base {

	/**
	 * Get widget name.
	 *
	 * @since 1.2.0
	 * @return string
	 */
	public function get_name(): string {
		return 'captwiki-woo-cart-page';
	}

	/**
	 * Get widget title.
	 *
	 * @since 1.2.0
	 * @return string
	 */
	public function get_title(): string {
		return esc_html__( 'Cart Page', 'captain-widgets-kit' );
	}

	/**
	 * Get widget icon.
	 *
	 * @since 1.2.0
	 * @return string
	 */
	public function get_icon(): string {
		return 'eicon-cart captwiki-el-logo';
	}

	/**
	 * Get widget categories.
	 *
	 * @since 1.2.0
	 * @return array
	 */
	public function get_categories(): array {
		return array( 'captwiki-woo-commerce' );
	}

	/**
	 * Get widget keywords.
	 *
	 * @since 1.2.0
	 * @return array
	 */
	public function get_keywords(): array {
		return array( 'woocommerce', 'woo', 'cart', 'basket', 'totals', 'coupon', 'captain-widgets-kit' );
	}

	/**
	 * Disable Elementor's default inner wrapper.
	 *
	 * @since 1.2.0
	 * @return bool
	 */
	public function has_widget_inner_wrapper(): bool {
		return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
	}

	/**
	 * Available visual styles.
	 *
	 * @since 1.2.0
	 * @return array
	 */
	private function captwiki_style_options(): array {
		return array(
			'style-1' => esc_html__( 'Style 1 – Minimal', 'captain-widgets-kit' ),
			'style-2' => esc_html__( 'Style 2 – Boxed', 'captain-widgets-kit' ),
			'style-3' => esc_html__( 'Style 3 – Modern', 'captain-widgets-kit' ),
		);
	}

	/**
	 * Register controls.
	 *
	 * @since 1.2.0
	 */
	protected function register_controls(): void {
		$this->register_content_controls();
		$this->register_table_style_controls();
		$this->register_quantity_style_controls();
		$this->register_coupon_style_controls();
		$this->register_button_style_controls();
		$this->register_checkout_button_style_controls();
		$this->register_totals_style_controls();
	}

	/**
	 * Content tab controls.
	 *
	 * @since 1.2.0
	 */
	private function register_content_controls(): void {

		$this->start_controls_section(
			'section_content',
			array(
				'label' => esc_html__( 'Cart', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);

		$this->add_control(
			'widget_style',
			array(
				'label'   => esc_html__( 'Style', 'captain-widgets-kit' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'style-1',
				'options' => $this->captwiki_style_options(),
			)
		);

		$this->add_control(
			'cart_note',
			array(
				'type'            => Controls_Manager::RAW_HTML,
				'raw'             => esc_html__( 'The cart renders fully on the front-end. In the editor it appears only when the cart has items.', 'captain-widgets-kit' ),
				'content_classes' => 'elementor-descriptor',
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Cart table style controls.
	 *
	 * @since 1.2.0
	 */
	private function register_table_style_controls(): void {

		$table_selector = '{{WRAPPER}} .captwiki-woo-cart .shop_table';

		$this->start_controls_section(
			'section_style_table',
			array(
				'label' => esc_html__( 'Cart Table', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_control(
			'table_head_heading',
			array(
				'label' => esc_html__( 'Table Header', 'captain-widgets-kit' ),
				'type'  => Controls_Manager::HEADING,
			)
		);

		$this->add_control(
			'table_head_bg',
			array(
				'label'     => esc_html__( 'Background', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$table_selector . ' thead th' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'table_head_color',
			array(
				'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$table_selector . ' thead th' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'table_body_heading',
			array(
				'label'     => esc_html__( 'Table Body', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_control(
			'table_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$table_selector . ' td, ' . $table_selector . ' td a' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'table_border_color',
			array(
				'label'     => esc_html__( 'Border Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$table_selector . ', ' . $table_selector . ' th, ' . $table_selector . ' td' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'table_typography',
				'selector' => $table_selector . ' td, ' . $table_selector . ' th',
			)
		);

		$this->add_responsive_control(
			'table_cell_padding',
			array(
				'label'      => esc_html__( 'Cell Padding', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em' ),
				'selectors'  => array(
					$table_selector . ' th, ' . $table_selector . ' td' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Quantity field style controls.
	 *
	 * @since 1.2.0
	 */
	private function register_quantity_style_controls(): void {

		$qty_selector = '{{WRAPPER}} .captwiki-woo-cart .quantity .qty';

		$this->start_controls_section(
			'section_style_quantity',
			array(
				'label' => esc_html__( 'Quantity', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_control(
			'quantity_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$qty_selector => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'quantity_bg_color',
			array(
				'label'     => esc_html__( 'Background Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$qty_selector => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'quantity_border',
				'selector' => $qty_selector,
			)
		);

		$this->add_responsive_control(
			'quantity_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					$qty_selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'quantity_width',
			array(
				'label'      => esc_html__( 'Field Width', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', 'em' ),
				'range'      => array( 'px' => array( 'min' => 40, 'max' => 200, 'step' => 1 ) ),
				'selectors'  => array(
					$qty_selector => 'width: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Coupon field style controls.
	 *
	 * @since 1.2.0
	 */
	private function register_coupon_style_controls(): void {

		$input_selector  = '{{WRAPPER}} .captwiki-woo-cart .coupon .input-text';
		$button_selector = '{{WRAPPER}} .captwiki-woo-cart .coupon button';

		$this->start_controls_section(
			'section_style_coupon',
			array(
				'label' => esc_html__( 'Coupon', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_control(
			'coupon_input_heading',
			array(
				'label' => esc_html__( 'Input', 'captain-widgets-kit' ),
				'type'  => Controls_Manager::HEADING,
			)
		);

		$this->add_control(
			'coupon_input_color',
			array(
				'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$input_selector => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'coupon_input_border',
				'selector' => $input_selector,
			)
		);

		$this->add_responsive_control(
			'coupon_input_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					$input_selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'coupon_button_heading',
			array(
				'label'     => esc_html__( 'Apply Button', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->start_controls_tabs( 'tabs_coupon_button' );

			$this->start_controls_tab(
				'tab_coupon_btn_normal',
				array( 'label' => esc_html__( 'Normal', 'captain-widgets-kit' ) )
			);

			$this->add_control(
				'coupon_button_color',
				array(
					'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						$button_selector => 'color: {{VALUE}};',
					),
				)
			);

			$this->add_control(
				'coupon_button_bg',
				array(
					'label'     => esc_html__( 'Background Color', 'captain-widgets-kit' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						$button_selector => 'background-color: {{VALUE}};',
					),
				)
			);

			$this->end_controls_tab();

			$this->start_controls_tab(
				'tab_coupon_btn_hover',
				array( 'label' => esc_html__( 'Hover', 'captain-widgets-kit' ) )
			);

			$this->add_control(
				'coupon_button_color_hover',
				array(
					'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						$button_selector . ':hover' => 'color: {{VALUE}};',
					),
				)
			);

			$this->add_control(
				'coupon_button_bg_hover',
				array(
					'label'     => esc_html__( 'Background Color', 'captain-widgets-kit' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						$button_selector . ':hover' => 'background-color: {{VALUE}};',
					),
				)
			);

			$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->end_controls_section();
	}

	/**
	 * Action button (update cart) style controls.
	 *
	 * @since 1.2.0
	 */
	private function register_button_style_controls(): void {

		$button_selector = '{{WRAPPER}} .captwiki-woo-cart button[name="update_cart"]';

		$this->start_controls_section(
			'section_style_button',
			array(
				'label' => esc_html__( 'Update Cart Button', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'button_typography',
				'selector' => $button_selector,
			)
		);

		$this->start_controls_tabs( 'tabs_button_colors' );

			$this->start_controls_tab(
				'tab_button_normal',
				array( 'label' => esc_html__( 'Normal', 'captain-widgets-kit' ) )
			);

			$this->add_control(
				'button_text_color',
				array(
					'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						$button_selector => 'color: {{VALUE}};',
					),
				)
			);

			$this->add_group_control(
				Group_Control_Background::get_type(),
				array(
					'name'     => 'button_background',
					'label'    => esc_html__( 'Background', 'captain-widgets-kit' ),
					'types'    => array( 'classic', 'gradient' ),
					'selector' => $button_selector,
					'exclude'  => array( 'image' ),
				)
			);

			$this->end_controls_tab();

			$this->start_controls_tab(
				'tab_button_hover',
				array( 'label' => esc_html__( 'Hover', 'captain-widgets-kit' ) )
			);

			$this->add_control(
				'button_text_color_hover',
				array(
					'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						$button_selector . ':hover' => 'color: {{VALUE}};',
					),
				)
			);

			$this->add_group_control(
				Group_Control_Background::get_type(),
				array(
					'name'     => 'button_background_hover',
					'label'    => esc_html__( 'Background', 'captain-widgets-kit' ),
					'types'    => array( 'classic', 'gradient' ),
					'selector' => $button_selector . ':hover',
					'exclude'  => array( 'image' ),
				)
			);

			$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->add_control( 'divider_button_box', array( 'type' => Controls_Manager::DIVIDER ) );

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'button_border',
				'selector' => $button_selector,
			)
		);

		$this->add_responsive_control(
			'button_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					$button_selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'button_padding',
			array(
				'label'      => esc_html__( 'Padding', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					$button_selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Proceed-to-checkout button style controls.
	 *
	 * @since 1.2.0
	 */
	private function register_checkout_button_style_controls(): void {

		$button_selector = '{{WRAPPER}} .captwiki-woo-cart .wc-proceed-to-checkout .checkout-button';

		$this->start_controls_section(
			'section_style_checkout_button',
			array(
				'label' => esc_html__( 'Proceed to Checkout', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'checkout_button_typography',
				'selector' => $button_selector,
			)
		);

		$this->start_controls_tabs( 'tabs_checkout_button_colors' );

			$this->start_controls_tab(
				'tab_checkout_button_normal',
				array( 'label' => esc_html__( 'Normal', 'captain-widgets-kit' ) )
			);

			$this->add_control(
				'checkout_button_text_color',
				array(
					'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						$button_selector => 'color: {{VALUE}};',
					),
				)
			);

			$this->add_group_control(
				Group_Control_Background::get_type(),
				array(
					'name'     => 'checkout_button_background',
					'label'    => esc_html__( 'Background', 'captain-widgets-kit' ),
					'types'    => array( 'classic', 'gradient' ),
					'selector' => $button_selector,
					'exclude'  => array( 'image' ),
				)
			);

			$this->end_controls_tab();

			$this->start_controls_tab(
				'tab_checkout_button_hover',
				array( 'label' => esc_html__( 'Hover', 'captain-widgets-kit' ) )
			);

			$this->add_control(
				'checkout_button_text_color_hover',
				array(
					'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						$button_selector . ':hover' => 'color: {{VALUE}};',
					),
				)
			);

			$this->add_group_control(
				Group_Control_Background::get_type(),
				array(
					'name'     => 'checkout_button_background_hover',
					'label'    => esc_html__( 'Background', 'captain-widgets-kit' ),
					'types'    => array( 'classic', 'gradient' ),
					'selector' => $button_selector . ':hover',
					'exclude'  => array( 'image' ),
				)
			);

			$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->add_control( 'divider_checkout_button_box', array( 'type' => Controls_Manager::DIVIDER ) );

		$this->add_responsive_control(
			'checkout_button_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					$button_selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'checkout_button_box_shadow',
				'selector' => $button_selector,
			)
		);

		$this->add_responsive_control(
			'checkout_button_padding',
			array(
				'label'      => esc_html__( 'Padding', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					$button_selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Cart totals box style controls.
	 *
	 * @since 1.2.0
	 */
	private function register_totals_style_controls(): void {

		$totals_selector = '{{WRAPPER}} .captwiki-woo-cart .cart_totals';

		$this->start_controls_section(
			'section_style_totals',
			array(
				'label' => esc_html__( 'Cart Totals', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_control(
			'totals_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$totals_selector . ', ' . $totals_selector . ' th, ' . $totals_selector . ' td' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'totals_heading_color',
			array(
				'label'     => esc_html__( 'Heading Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$totals_selector . ' h2' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'totals_background',
				'label'    => esc_html__( 'Background', 'captain-widgets-kit' ),
				'types'    => array( 'classic', 'gradient' ),
				'selector' => $totals_selector,
				'exclude'  => array( 'image' ),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'totals_border',
				'selector' => $totals_selector,
			)
		);

		$this->add_responsive_control(
			'totals_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					$totals_selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'totals_padding',
			array(
				'label'      => esc_html__( 'Padding', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					$totals_selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Output an editor-only notice.
	 *
	 * @since 1.2.0
	 * @param string $message Notice text.
	 */
	private function captwiki_render_editor_notice( string $message ): void {

		if ( ! \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
			return;
		}

		echo '<div class="captwiki-woo-cart captwiki-woo-cart--notice">';
			echo '<p>' . esc_html( $message ) . '</p>';
		echo '</div>';
	}

	/**
	 * Render widget output on the frontend.
	 *
	 * @since 1.2.0
	 */
	protected function render(): void {

		if ( ! class_exists( 'WooCommerce' ) ) {
			$this->captwiki_render_editor_notice( esc_html__( 'WooCommerce is required for the Cart Page widget.', 'captain-widgets-kit' ) );
			return;
		}

		$settings = $this->get_settings_for_display();

		$allowed_styles = array_keys( $this->captwiki_style_options() );
		$style          = ! empty( $settings['widget_style'] ) && in_array( $settings['widget_style'], $allowed_styles, true ) ? $settings['widget_style'] : 'style-1';

		// Load only the active style stylesheet, depending on the common one.
		wp_enqueue_style(
			'captwiki-woo-cart-page-' . $style,
			CAPTWIKI_URL . 'assets/css/widgets/woo-cart/captwiki-woo-cart-' . $style . '.css',
			array( 'captwiki-woo-cart-page' ),
			CAPTWIKI_VERSION
		);

		// In the editor an empty cart shows the empty-cart message; let the user know.
		if ( \Elementor\Plugin::$instance->editor->is_edit_mode()
			&& function_exists( 'WC' ) && WC()->cart && WC()->cart->is_empty() ) {
			$this->captwiki_render_editor_notice( esc_html__( 'Add a product to the cart to preview it here. It will display normally on the live site.', 'captain-widgets-kit' ) );
			return;
		}

		$wrapper_classes = array(
			'captwiki-woo-cart',
			'captwiki-' . $style,
			'captwiki-widget-' . $this->get_id(),
		);

		echo '<div class="' . esc_attr( implode( ' ', $wrapper_classes ) ) . '">';
			// Trusted WooCommerce cart markup (forms/inputs wp_kses_post would strip).
			echo do_shortcode( '[woocommerce_cart]' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
		echo '</div>';
	}
}
