Upgarded to 4.17.4
This commit is contained in:
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Add to cart component.
|
||||
*/
|
||||
@ -18,10 +20,11 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Add To Cart', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Add To Cart', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_add_to_cart';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Add To Cart', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Add To Cart', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_add_to_cart';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
@ -32,11 +35,10 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
),
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'text' => array(
|
||||
'title' => et_builder_i18n( 'Text' ),
|
||||
'priority' => 45,
|
||||
'field_label' => array(
|
||||
'title' => esc_html__( 'Field Labels', 'et_builder' ),
|
||||
),
|
||||
'header' => array(
|
||||
'header' => array(
|
||||
'title' => esc_html__( 'Heading Text', 'et_builder' ),
|
||||
'priority' => 49,
|
||||
'tabbed_subtoggles' => true,
|
||||
@ -67,7 +69,7 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
),
|
||||
'width' => array(
|
||||
'width' => array(
|
||||
'title' => et_builder_i18n( 'Sizing' ),
|
||||
'priority' => 80,
|
||||
),
|
||||
@ -77,23 +79,23 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
|
||||
$this->advanced_fields = array(
|
||||
'fonts' => array(
|
||||
'body' => array(
|
||||
'label' => et_builder_i18n( 'Text' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%%, %%order_class%% a, %%order_class%% label, %%order_class%%.et_pb_module .et_pb_module_inner .stock',
|
||||
'important' => 'all',
|
||||
'field_label' => array(
|
||||
'label' => esc_html__( 'Field Labels', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% label',
|
||||
)
|
||||
),
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.3em',
|
||||
),
|
||||
'hide_text_align' => true,
|
||||
'toggle_slug' => 'text',
|
||||
'font' => array(
|
||||
'font' => array(
|
||||
'default' => '|700|||||||',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'toggle_slug' => 'field_label',
|
||||
),
|
||||
),
|
||||
'background' => array(
|
||||
@ -107,21 +109,17 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
'text' => array(
|
||||
'use_background_layout' => true,
|
||||
'use_background_layout' => false,
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% td.label',
|
||||
'text_shadow' => '%%order_class%% td.label',
|
||||
),
|
||||
'options' => array(
|
||||
'text_orientation' => array(
|
||||
'text_orientation' => array(
|
||||
'default' => 'left',
|
||||
),
|
||||
'background_layout' => array(
|
||||
'default' => 'light',
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
),
|
||||
),
|
||||
'text_shadow' => array(
|
||||
// Don't add text-shadow fields since they already are via font-options.
|
||||
'default' => false,
|
||||
),
|
||||
'button' => array(
|
||||
'button' => array(
|
||||
'label' => et_builder_i18n( 'Button' ),
|
||||
@ -343,7 +341,7 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
*/
|
||||
public function get_fields() {
|
||||
$fields = array(
|
||||
'product' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'product' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'product',
|
||||
array(
|
||||
'default' => ET_Builder_Module_Helper_Woocommerce_Modules::get_product_default(),
|
||||
@ -352,7 +350,7 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
),
|
||||
)
|
||||
),
|
||||
'product_filter' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'product_filter' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'product_filter',
|
||||
array(
|
||||
'computed_affects' => array(
|
||||
@ -360,7 +358,7 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
),
|
||||
)
|
||||
),
|
||||
'show_quantity' => array(
|
||||
'show_quantity' => array(
|
||||
'label' => esc_html__( 'Show Quantity Field', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
@ -374,7 +372,7 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_stock' => array(
|
||||
'show_stock' => array(
|
||||
'label' => esc_html__( 'Show Stock', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
@ -388,7 +386,22 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'__add_to_cart' => array(
|
||||
'field_label_position' => array(
|
||||
'label' => esc_html__( 'Fields Label Position', 'et_builder' ),
|
||||
'description' => esc_html__( 'Set the position of the field labels.', 'et_builder' ),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'inline' => __( 'Inline', 'et_builder' ),
|
||||
'stacked' => __( 'Stacked', 'et_builder' ),
|
||||
),
|
||||
'default' => 'default',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'field_label',
|
||||
'mobile_options' => true,
|
||||
'priority' => 15,
|
||||
),
|
||||
'__add_to_cart' => array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
'ET_Builder_Module_Woocommerce_Add_To_Cart',
|
||||
@ -407,22 +420,75 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the Add to Cart form's action.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*
|
||||
* @param string $permalink Permalink.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function replace_add_to_cart_form_action( $permalink ) {
|
||||
$the_id = et_core_page_resource_get_the_ID();
|
||||
if ( 0 === absint( et_core_page_resource_get_the_ID() ) ) {
|
||||
return $permalink;
|
||||
}
|
||||
|
||||
$link = get_permalink( $the_id );
|
||||
|
||||
// Validate if Post exists.
|
||||
return $link ? $link : $permalink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get add to cart markup as string
|
||||
*
|
||||
* @since 4.14.0 Update Add to Cart Form action {@see https://github.com/elegantthemes/Divi/issues/16682}
|
||||
*
|
||||
* @since 4.4.0 Fixed compatibility w/ WooCommerce Product Add-ons
|
||||
* @see https://github.com/elegantthemes/Divi/issues/19116
|
||||
*
|
||||
* @param array $args Additional arguments.
|
||||
* @param array $args Arguments from Computed Prop AJAX call.
|
||||
* @param array $conditional_tags Conditional Tags.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_add_to_cart( $args = array() ) {
|
||||
return et_builder_wc_render_module_template(
|
||||
public static function get_add_to_cart( $args = array(), $conditional_tags = array() ) {
|
||||
$is_tb = 'true' === et_()->array_get( $conditional_tags, 'is_tb', 'false' );
|
||||
$is_bfb = 'true' === et_()->array_get( $conditional_tags, 'is_bfb', 'false' );
|
||||
$is_bfb_activated = 'true' === et_()->array_get( $conditional_tags, 'is_bfb_activated', 'false' );
|
||||
$is_builder = $is_tb || $is_bfb || $is_bfb_activated || is_et_pb_preview();
|
||||
|
||||
if ( ! $is_builder ) {
|
||||
add_filter(
|
||||
'woocommerce_add_to_cart_form_action',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Add_To_Cart',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- This is a function call.
|
||||
'replace_add_to_cart_form_action'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$output = et_builder_wc_render_module_template(
|
||||
'woocommerce_template_single_add_to_cart',
|
||||
$args,
|
||||
array( 'product', 'post' )
|
||||
);
|
||||
|
||||
if ( ! $is_builder ) {
|
||||
remove_filter(
|
||||
'woocommerce_add_to_cart_form_action',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Add_To_Cart',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- This is a function call.
|
||||
'replace_add_to_cart_form_action'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -452,12 +518,18 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
$multi_view_attrs = $multi_view->render_attrs(
|
||||
array(
|
||||
'classes' => array(
|
||||
'et_pb_hide_input_quantity' => array(
|
||||
'et_pb_hide_input_quantity' => array(
|
||||
'show_quantity' => 'off',
|
||||
),
|
||||
'et_pb_hide_stock' => array(
|
||||
'et_pb_hide_stock' => array(
|
||||
'show_stock' => 'off',
|
||||
),
|
||||
'et_pb_fields_label_position_inline' => array(
|
||||
'field_label_position' => 'inline',
|
||||
),
|
||||
'et_pb_fields_label_position_stacked' => array(
|
||||
'field_label_position' => 'stacked',
|
||||
),
|
||||
),
|
||||
),
|
||||
false,
|
||||
@ -562,6 +634,9 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
$this->add_classname( 'et_pb_with_focus_border' );
|
||||
}
|
||||
|
||||
$fields_label_position = et_()->array_get( $this->props, 'field_label_position', 'inline' );
|
||||
$this->add_classname( "et_pb_fields_label_position_{$fields_label_position}" );
|
||||
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::process_background_layout_data( $render_slug, $this );
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::process_custom_button_icons( $render_slug, $this );
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Additional Info component.
|
||||
*/
|
||||
@ -20,10 +22,11 @@ class ET_Builder_Module_Woocommerce_Additional_Info extends ET_Builder_Module {
|
||||
* @since 4.0.6 Implemented Attribute Row, Title and Body Custom CSS fields.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Additional Info', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Additional Info', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_additional_info';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Information', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Information', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_additional_info';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
@ -34,7 +37,7 @@ class ET_Builder_Module_Woocommerce_Additional_Info extends ET_Builder_Module {
|
||||
),
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'text' => array(
|
||||
'text' => array(
|
||||
'title' => et_builder_i18n( 'Text' ),
|
||||
'priority' => 45,
|
||||
'tabbed_subtoggles' => true,
|
||||
@ -50,9 +53,21 @@ class ET_Builder_Module_Woocommerce_Additional_Info extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
),
|
||||
'header' => array(
|
||||
'header' => array(
|
||||
'title' => esc_html__( 'Title Text', 'et_builder' ),
|
||||
),
|
||||
'table' => array(
|
||||
'title' => esc_html__( 'Table', 'et_builder' ),
|
||||
'priority' => 70,
|
||||
),
|
||||
'table_row' => array(
|
||||
'title' => esc_html__( 'Table Row', 'et_builder' ),
|
||||
'priority' => 75,
|
||||
),
|
||||
'table_cell' => array(
|
||||
'title' => esc_html__( 'Table Cell', 'et_builder' ),
|
||||
'priority' => 80,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -155,6 +170,211 @@ class ET_Builder_Module_Woocommerce_Additional_Info extends ET_Builder_Module {
|
||||
'default' => false,
|
||||
),
|
||||
'button' => false,
|
||||
'form_field' => array(
|
||||
'table' => array(
|
||||
'label' => esc_html__( 'Table', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes',
|
||||
),
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes',
|
||||
),
|
||||
'use_padding' => false,
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'table' => array(
|
||||
'label_prefix' => 'Table',
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% table.shop_attributes',
|
||||
'border_radii' => '%%order_class%% table.shop_attributes',
|
||||
),
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'dotted',
|
||||
),
|
||||
'composite' => array(
|
||||
'border_top' => array(
|
||||
'border_width_top' => '1px',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes',
|
||||
),
|
||||
),
|
||||
),
|
||||
'table_row' => array(
|
||||
'label' => esc_html__( 'Table Row', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr',
|
||||
),
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr th, %%order_class%% table.shop_attributes tr td',
|
||||
),
|
||||
'use_margin' => false,
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'table_row' => array(
|
||||
'label_prefix' => 'Table Row',
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
// Accepts only string and not array. Hence using `implode`.
|
||||
'border_radii' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_attributes th',
|
||||
'%%order_class%% table.shop_attributes td',
|
||||
)
|
||||
),
|
||||
'border_styles' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_attributes th',
|
||||
'%%order_class%% table.shop_attributes td',
|
||||
)
|
||||
),
|
||||
),
|
||||
'important' => true,
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '1px',
|
||||
'style' => 'dotted',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr',
|
||||
),
|
||||
),
|
||||
),
|
||||
'table_row' => array(
|
||||
'label' => esc_html__( 'Table Row', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr',
|
||||
),
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr th, %%order_class%% table.shop_attributes tr td',
|
||||
),
|
||||
'use_margin' => false,
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'table_row' => array(
|
||||
'label_prefix' => 'Table Row',
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
// Accepts only string and not array. Hence using `implode`.
|
||||
'border_radii' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_attributes th',
|
||||
'%%order_class%% table.shop_attributes td',
|
||||
)
|
||||
),
|
||||
'border_styles' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_attributes th',
|
||||
'%%order_class%% table.shop_attributes td',
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '1px',
|
||||
'style' => 'dotted',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr',
|
||||
),
|
||||
),
|
||||
),
|
||||
'table_cell' => array(
|
||||
'label' => esc_html__( 'Table Cell', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr th, %%order_class%% table.shop_attributes tr td',
|
||||
),
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_attributes tr th',
|
||||
'%%order_class%% table.shop_attributes tr td',
|
||||
)
|
||||
),
|
||||
),
|
||||
'use_margin' => false,
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'table_cell' => array(
|
||||
'label_prefix' => 'Table Cell',
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% table.shop_attributes tr th,%%order_class%% table.shop_attributes tr td',
|
||||
'border_radii' => '%%order_class%% table.shop_attributes tr th, %%order_class%% table.shop_attributes tr td',
|
||||
),
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '1px',
|
||||
'style' => 'dotted',
|
||||
),
|
||||
'composite' => array(
|
||||
'border_top' => array(
|
||||
'border_width_top' => '1px',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr th, %%order_class%% table.shop_attributes td',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->custom_css_fields = array(
|
||||
@ -332,6 +552,24 @@ class ET_Builder_Module_Woocommerce_Additional_Info extends ET_Builder_Module {
|
||||
|
||||
add_filter( "et_builder_module_{$render_slug}_outer_wrapper_attrs", array( $this, 'add_multi_view_attrs' ), 10, 2 );
|
||||
|
||||
$table_row_bg_color = et_()->array_get( $this->props, 'table_row_background_color', '' );
|
||||
|
||||
if ( ! empty( $table_row_bg_color ) ) {
|
||||
ET_Builder_Element::set_style(
|
||||
$render_slug,
|
||||
array(
|
||||
'selector' => implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% table.shop_attributes tr:nth-child(even) th',
|
||||
'%%order_class%% table.shop_attributes tr:nth-child(even) td',
|
||||
)
|
||||
),
|
||||
'declaration' => 'background: inherit',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$output = self::get_additional_info( $this->props );
|
||||
|
||||
// Render empty string if no output is generated to avoid unwanted vertical space.
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Breadcrumb component.
|
||||
*/
|
||||
@ -25,10 +27,11 @@ class ET_Builder_Module_Woocommerce_Breadcrumb extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Breadcrumb', 'et_builder' );
|
||||
$this->name = esc_html__( 'Woo Breadcrumbs', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Breadcrumbs', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_breadcrumb';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
$this->main_css_element = '%%order_class%% .woocommerce-breadcrumb';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
@ -96,6 +99,10 @@ class ET_Builder_Module_Woocommerce_Breadcrumb extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
'background' => array(
|
||||
'css' => array(
|
||||
// Backgrounds need to be applied to module wrapper.
|
||||
'main' => '%%order_class%%.et_pb_wc_breadcrumb',
|
||||
),
|
||||
'settings' => array(
|
||||
'color' => 'alpha',
|
||||
),
|
||||
@ -245,7 +252,7 @@ class ET_Builder_Module_Woocommerce_Breadcrumb extends ET_Builder_Module {
|
||||
$layout_post_id = ET_Builder_Element::get_layout_id();
|
||||
$is_fb = et_core_is_fb_enabled() && $main_query_post_id === $layout_post_id;
|
||||
|
||||
if ( ! et_fb_is_resolve_post_content_callback_ajax() && ( $is_fb || et_fb_is_builder_ajax() || et_fb_is_computed_callback_ajax() ) ) {
|
||||
if ( ! et_fb_is_resolve_post_content_callback_ajax() && ( $is_fb || et_fb_is_builder_ajax() || et_fb_is_computed_callback_ajax() || is_et_pb_preview() ) ) {
|
||||
$args = wp_parse_args(
|
||||
array(
|
||||
'breadcrumb_home_text' => '%HOME_TEXT%',
|
||||
|
File diff suppressed because it is too large
Load Diff
1630
includes/builder/module/woocommerce/CartProducts.php
Normal file
1630
includes/builder/module/woocommerce/CartProducts.php
Normal file
File diff suppressed because it is too large
Load Diff
1121
includes/builder/module/woocommerce/CartTotals.php
Normal file
1121
includes/builder/module/woocommerce/CartTotals.php
Normal file
File diff suppressed because it is too large
Load Diff
587
includes/builder/module/woocommerce/CheckoutAdditionalInfo.php
Normal file
587
includes/builder/module/woocommerce/CheckoutAdditionalInfo.php
Normal file
@ -0,0 +1,587 @@
|
||||
<?php
|
||||
/**
|
||||
* WooCommerce Modules: ET_Builder_Module_Woocommerce_Checkout_Additional_Info class
|
||||
*
|
||||
* The ET_Builder_Module_Woocommerce_Checkout_Additional_Info Class is responsible for rendering the
|
||||
* Checkout Additional Info section using the WooCommerce template.
|
||||
*
|
||||
* @package Divi\Builder
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Checkout Additional Info component.
|
||||
*/
|
||||
final class ET_Builder_Module_Woocommerce_Checkout_Additional_Info extends ET_Builder_Module {
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
* @since 4.14.0 Fixed PHP Warnings {@link https://github.com/elegantthemes/Divi/issues/22104}
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Checkout Information', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Checkout Information', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_checkout_additional_info';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
'toggles' => array(
|
||||
'elements' => esc_html__( 'Elements', 'et_builder' ),
|
||||
),
|
||||
),
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'title' => array(
|
||||
'title' => esc_html__( 'Title Text', 'et_builder' ),
|
||||
'priority' => 49,
|
||||
),
|
||||
'field_label' => array(
|
||||
'title' => esc_html__( 'Field Labels', 'et_builder' ),
|
||||
'priority' => 60,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->advanced_fields = array(
|
||||
'fonts' => array(
|
||||
'title' => array(
|
||||
'label' => esc_html__( 'Title', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% h3',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '22px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1em',
|
||||
),
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'title',
|
||||
),
|
||||
'field_label' => array(
|
||||
'label' => esc_html__( 'Field Label', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% form .form-row label',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '2em',
|
||||
),
|
||||
'toggle_slug' => 'field_label',
|
||||
),
|
||||
),
|
||||
'text' => array(
|
||||
'use_background_layout' => false,
|
||||
'use_text_orientation' => true,
|
||||
),
|
||||
'button' => false,
|
||||
'link_options' => false,
|
||||
'form_field' => array(
|
||||
'form_field' => array(
|
||||
'label' => esc_html__( 'Fields', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% form .form-row .input-text',
|
||||
'focus_text_color' => implode(
|
||||
',',
|
||||
[
|
||||
'.woocommerce %%order_class%% form .form-row .input-text:focus',
|
||||
'.woocommerce-page %%order_class%% form .form-row .input-text:focus',
|
||||
]
|
||||
),
|
||||
),
|
||||
'box_shadow' => false,
|
||||
'border_styles' => array(
|
||||
'form_field' => array(
|
||||
'label_prefix' => esc_html__( 'Fields', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% .et_pb_module_inner form .form-row textarea',
|
||||
'border_radii' => '%%order_class%% .et_pb_module_inner form .form-row textarea',
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'solid',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'form_field_focus' => array(
|
||||
'label_prefix' => esc_html__( 'Fields Focus', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% form .form-row textarea.input-text:focus',
|
||||
'border_radii' => '%%order_class%% form .form-row textarea.input-text:focus',
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'solid',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'font_field' => array(
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% form .form-row .input-text',
|
||||
'%%order_class%% form .form-row .input-text::placeholder',
|
||||
'%%order_class%% form .form-row .input-text::-webkit-input-placeholder',
|
||||
'%%order_class%% form .form-row .input-text::-moz-placeholder',
|
||||
'%%order_class%% form .form-row .input-text:-ms-input-placeholder',
|
||||
)
|
||||
),
|
||||
'hover' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% form .input-text',
|
||||
'%%order_class%% form .input-text:hover::placeholder',
|
||||
'%%order_class%% form .input-text:hover::-webkit-input-placeholder',
|
||||
'%%order_class%% form .input-text:hover::-moz-placeholder',
|
||||
'%%order_class%% form .input-text:hover:-ms-input-placeholder',
|
||||
)
|
||||
),
|
||||
// Required to override default WooCommerce styles.
|
||||
'important' => array( 'line-height', 'font', 'size' ),
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.7em',
|
||||
),
|
||||
),
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% form .form-row textarea',
|
||||
'padding' => '%%order_class%% form .form-row textarea.input-text',
|
||||
),
|
||||
'custom_padding' => array(
|
||||
'default' => '15px|15px|15px|15px|false|false',
|
||||
),
|
||||
),
|
||||
'width' => array(),
|
||||
'toggle_priority' => 65,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->custom_css_fields = array(
|
||||
'title_text' => array(
|
||||
'label' => esc_html__( 'Title Text', 'et_builder' ),
|
||||
'selector' => '%%order_class%% h3',
|
||||
),
|
||||
'field_label' => array(
|
||||
'label' => esc_html__( 'Field Label', 'et_builder' ),
|
||||
'selector' => '%%order_class%% form .form-row label',
|
||||
),
|
||||
'fields' => array(
|
||||
'label' => esc_html__( 'Fields', 'et_builder' ),
|
||||
'selector' => '%%order_class%% form .input-text',
|
||||
),
|
||||
'fields_placeholder' => array(
|
||||
'label' => esc_html__( 'Fields Placeholder', 'et_builder' ),
|
||||
'selector' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% form .form-row .input-text::placeholder',
|
||||
'%%order_class%% form .form-row .input-text::-webkit-input-placeholder',
|
||||
'%%order_class%% form .form-row .input-text::-moz-placeholder',
|
||||
'%%order_class%% form .form-row .input-text:-ms-input-placeholder',
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->help_videos = array(
|
||||
array(
|
||||
'id' => esc_html( '7X03vBPYJ1o' ),
|
||||
'name' => esc_html__( 'Divi WooCommerce Modules', 'et_builder' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_fields() {
|
||||
$fields = array(
|
||||
'show_title' => array(
|
||||
'label' => esc_html__( 'Show Title', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn title on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'placeholder_color' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'placeholder_color'
|
||||
),
|
||||
'__checkout_additional_info' => array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Additional_Info',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'get_additional_info'
|
||||
),
|
||||
'computed_depends_on' => array(
|
||||
|
||||
/*
|
||||
* `depends_on` arg is required. Otherwise AJAX will return null.
|
||||
* @see et_pb_process_computed_property().
|
||||
* `product` will not be processed since there is no definition in
|
||||
* @see ET_Builder_Module_Woocommerce_Checkout_Order::get_fields()
|
||||
*/
|
||||
'product',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset hooks.
|
||||
*/
|
||||
public static function maybe_reset_hooks( $conditional_tags ) {
|
||||
$is_tb = et_()->array_get( $conditional_tags, 'is_tb', false );
|
||||
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_coupon_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_login_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_order_review();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_payment();
|
||||
|
||||
if ( ! et_fb_is_computed_callback_ajax() && ! $is_tb ) {
|
||||
remove_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Additional_Info',
|
||||
'swap_template',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle hooks.
|
||||
*/
|
||||
public static function maybe_handle_hooks( $conditional_tags ) {
|
||||
$is_tb = et_()->array_get( $conditional_tags, 'is_tb', false );
|
||||
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_coupon_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_login_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_order_review();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_payment();
|
||||
|
||||
if ( ! et_fb_is_computed_callback_ajax() && ! $is_tb ) {
|
||||
add_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Additional_Info',
|
||||
'swap_template',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke WooCommerce hooks.
|
||||
*
|
||||
* When Dynamic framework is enabled, some of WooCommerce's actions/filters
|
||||
* won't be invoked because of lazy loading.
|
||||
*
|
||||
* Since WooCommerce's hooks are required before render() they are
|
||||
* invoked using the `et_builder_module_lazy_shortcodes_registered` hook.
|
||||
*
|
||||
* @see et_builder_wc_init()
|
||||
* @see ET_Builder_Module_Shortcode_Manager::register_all_shortcodes()
|
||||
*/
|
||||
public static function maybe_invoke_woocommerce_hooks() {
|
||||
/*
|
||||
* The respective remove_filter is used at
|
||||
*
|
||||
* @see ET_Builder_Module_Woocommerce_Checkout_Additional_Info::get_additional_info()
|
||||
*/
|
||||
add_filter(
|
||||
'woocommerce_checkout_fields',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Additional_Info',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'modify_order_comments_rows'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the Checkout Information Textarea `rows` attribute.
|
||||
*
|
||||
* @param array $fields Array of checkout fields.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function modify_order_comments_rows( $fields ) {
|
||||
if ( ! is_array( $fields ) ) {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
if ( ! isset( $fields['order'] ) || ! isset( $fields['order']['order_comments'] ) ) {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
$fields['order']['order_comments']['custom_attributes']['rows'] = 4;
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_transition_fields_css_props() {
|
||||
$fields = parent::get_transition_fields_css_props();
|
||||
|
||||
$fields['placeholder_color'] = array(
|
||||
'color' => array(
|
||||
'%%order_class%% form .form-row textarea.input-text::placeholder',
|
||||
'%%order_class%% form .form-row textarea.input-text::-webkit-input-placeholder',
|
||||
'%%order_class%% form .form-row textarea.input-text::-moz-placeholder',
|
||||
'%%order_class%% form .form-row textarea.input-text:-ms-input-placeholder',
|
||||
),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps Checkout Order Details template.
|
||||
*
|
||||
* Coupon Remove Link must be shown in VB. Hence we swap the template.
|
||||
*
|
||||
* @param string $template Template.
|
||||
* @param string $template_name Template name.
|
||||
* @param array $args Arguments.
|
||||
* @param string $template_path Template path.
|
||||
* @param string $default_path Default path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function swap_template( $template, $template_name, $args, $template_path, $default_path ) {
|
||||
$is_template_override = in_array(
|
||||
$template_name,
|
||||
array(
|
||||
'checkout/form-checkout.php',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
if ( $is_template_override ) {
|
||||
return trailingslashit( ET_BUILDER_DIR ) . 'feature/woocommerce/templates/' . $template_name;
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Checkout Additional Info markup.
|
||||
*
|
||||
* @param array $args Settings used to render the module's output.
|
||||
* Refer ET_Builder_Element::props.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_additional_info( $args = array(), $conditional_tags = array() ) {
|
||||
self::maybe_handle_hooks( $conditional_tags );
|
||||
|
||||
$is_cart_empty = function_exists( 'WC' ) && isset( WC()->cart ) && WC()->cart->is_empty();
|
||||
|
||||
// Is Page Builder mode?.
|
||||
$is_pb_mode = et_fb_is_computed_callback_ajax() || is_et_pb_preview();
|
||||
|
||||
// Set dummy cart contents to output Additional Information when no product is in cart.
|
||||
if ( ( $is_cart_empty && $is_pb_mode ) || is_et_pb_preview() ) {
|
||||
add_filter(
|
||||
'woocommerce_get_cart_contents',
|
||||
array(
|
||||
'ET_Builder_Module_Helper_Woocommerce_Modules',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'set_dummy_cart_contents'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Show Checkout Additional Info module title.
|
||||
add_filter( 'woocommerce_cart_needs_shipping', '__return_false' );
|
||||
|
||||
add_filter(
|
||||
'woocommerce_checkout_fields',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Additional_Info',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'modify_order_comments_rows'
|
||||
)
|
||||
);
|
||||
|
||||
ob_start();
|
||||
|
||||
WC_Shortcode_Checkout::output( array() );
|
||||
|
||||
$markup = ob_get_clean();
|
||||
|
||||
remove_filter(
|
||||
'woocommerce_checkout_fields',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Additional_Info',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'modify_order_comments_rows'
|
||||
)
|
||||
);
|
||||
|
||||
// Reset showing Checkout Additional Info module title.
|
||||
remove_filter( 'woocommerce_cart_needs_shipping', '__return_false' );
|
||||
|
||||
if ( ( $is_cart_empty && $is_pb_mode ) || is_et_pb_preview() ) {
|
||||
remove_filter(
|
||||
'woocommerce_get_cart_contents',
|
||||
array(
|
||||
'ET_Builder_Module_Helper_Woocommerce_Modules',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'set_dummy_cart_contents'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
self::maybe_reset_hooks( $conditional_tags );
|
||||
|
||||
// Fallback.
|
||||
if ( ! is_string( $markup ) ) {
|
||||
$markup = '';
|
||||
}
|
||||
|
||||
return $markup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Multi view attributes to the Outer wrapper.
|
||||
*
|
||||
* Since we do not have control over the WooCommerce Additional Info markup,
|
||||
* we inject Multi view attributes on to the Outer wrapper.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*
|
||||
* @param array $outer_wrapper_attrs Outer wrapper attributes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_multi_view_attrs( $outer_wrapper_attrs ) {
|
||||
$multi_view = et_pb_multi_view_options( $this );
|
||||
|
||||
$multi_view_attrs = $multi_view->render_attrs(
|
||||
array(
|
||||
'classes' => array(
|
||||
'et_pb_wc_no_title' => array(
|
||||
'show_title' => 'off',
|
||||
),
|
||||
),
|
||||
),
|
||||
false,
|
||||
null,
|
||||
true
|
||||
);
|
||||
|
||||
if ( $multi_view_attrs && is_array( $multi_view_attrs ) ) {
|
||||
$outer_wrapper_attrs = array_merge( $outer_wrapper_attrs, $multi_view_attrs );
|
||||
}
|
||||
|
||||
return $outer_wrapper_attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the module output.
|
||||
*
|
||||
* @param array $attrs List of attributes.
|
||||
* @param string $content Content being processed.
|
||||
* @param string $render_slug Slug of module that is used for rendering output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render( $attrs, $content, $render_slug ) {
|
||||
if ( function_exists( 'is_order_received_page' )
|
||||
&& is_order_received_page() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Add classes to hide disabled elements.
|
||||
if ( 'off' === $this->prop( 'show_title', 'on' ) ) {
|
||||
$this->add_classname( 'et_pb_wc_no_title' );
|
||||
}
|
||||
|
||||
$this->add_classname( $this->get_text_orientation_classname() );
|
||||
|
||||
add_filter( "et_builder_module_{$render_slug}_outer_wrapper_attrs", array( $this, 'add_multi_view_attrs' ) );
|
||||
|
||||
// Placeholder Color.
|
||||
$placeholder_selectors = array(
|
||||
'%%order_class%% form .form-row textarea.input-text::placeholder',
|
||||
'%%order_class%% form .form-row textarea.input-text::-webkit-input-placeholder',
|
||||
'%%order_class%% form .form-row textarea.input-text::-moz-placeholder',
|
||||
'%%order_class%% form .form-row textarea.input-text:-ms-input-placeholder',
|
||||
);
|
||||
|
||||
$this->generate_styles(
|
||||
array(
|
||||
'base_attr_name' => 'placeholder_color',
|
||||
'selector' => join( ', ', $placeholder_selectors ),
|
||||
'hover_pseudo_selector_location' => 'suffix',
|
||||
'sticky_pseudo_selector_location' => 'prefix',
|
||||
'css_property' => 'color',
|
||||
'important' => false,
|
||||
'render_slug' => $render_slug,
|
||||
'type' => 'color',
|
||||
)
|
||||
);
|
||||
|
||||
global $wp;
|
||||
if ( ! empty( $wp->query_vars['order-pay'] ) ) {
|
||||
$this->add_classname( 'et_pb_wc_order_pay' );
|
||||
}
|
||||
|
||||
if ( isset( WC()->cart )
|
||||
&& ! is_null( WC()->cart && method_exists( WC()->cart, 'check_cart_items' ) )
|
||||
&& ! is_et_pb_preview() ) {
|
||||
$return = WC()->cart->check_cart_items();
|
||||
|
||||
if ( wc_notice_count( 'error' ) > 0 ) {
|
||||
$this->add_classname( 'et_pb_hide_module' );
|
||||
}
|
||||
}
|
||||
|
||||
$output = self::get_additional_info( $this->props );
|
||||
|
||||
return $this->_render_module_wrapper( $output, $render_slug );
|
||||
}
|
||||
}
|
||||
|
||||
new ET_Builder_Module_Woocommerce_Checkout_Additional_Info();
|
674
includes/builder/module/woocommerce/CheckoutBilling.php
Normal file
674
includes/builder/module/woocommerce/CheckoutBilling.php
Normal file
@ -0,0 +1,674 @@
|
||||
<?php
|
||||
/**
|
||||
* WooCommerce Modules: ET_Builder_Module_Woocommerce_Checkout_Billing class
|
||||
*
|
||||
* The ET_Builder_Module_Woocommerce_Checkout_Billing Class is responsible for rendering the
|
||||
* Checkout billing section using the WooCommerce template.
|
||||
*
|
||||
* @package Divi\Builder
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Checkout billing component.
|
||||
*/
|
||||
class ET_Builder_Module_Woocommerce_Checkout_Billing extends ET_Builder_Module {
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
* @since 4.14.0 Fixed PHP Warnings {@link https://github.com/elegantthemes/Divi/issues/22104}
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Checkout Billing', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Checkout Billing', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_checkout_billing';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'layout' => array(
|
||||
'title' => et_builder_i18n( 'Layout' ),
|
||||
'priority' => 45,
|
||||
),
|
||||
'title' => array(
|
||||
'title' => esc_html__( 'Title Text', 'et_builder' ),
|
||||
'priority' => 55,
|
||||
),
|
||||
'field_label' => array(
|
||||
'title' => esc_html__( 'Field Labels', 'et_builder' ),
|
||||
'priority' => 60,
|
||||
),
|
||||
'form_field' => array(
|
||||
'title' => esc_html__( 'Fields', 'et_builder' ),
|
||||
'priority' => 65,
|
||||
),
|
||||
'form_notice' => array(
|
||||
'title' => esc_html__( 'Form Notice', 'et_builder' ),
|
||||
'priority' => 70,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->advanced_fields = array(
|
||||
'fonts' => array(
|
||||
// Use `title` in place of `header` since `header` needs a workaround in Copy/Paste.
|
||||
'title' => array(
|
||||
'label' => esc_html__( 'Title', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% h3',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '22px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1em',
|
||||
),
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'title',
|
||||
),
|
||||
'field_label' => array(
|
||||
'label' => esc_html__( 'Field Label', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% form .form-row label',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '2em',
|
||||
),
|
||||
'toggle_slug' => 'field_label',
|
||||
),
|
||||
),
|
||||
'text' => array(
|
||||
'use_background_layout' => false,
|
||||
'use_text_orientation' => true,
|
||||
),
|
||||
'button' => false,
|
||||
'link_options' => false,
|
||||
'form_field' => array(
|
||||
'form_field' => array(
|
||||
'label' => esc_html__( 'Fields', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--default .select2-selection--single',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text',
|
||||
)
|
||||
),
|
||||
'background_color_hover' => implode(
|
||||
',',
|
||||
[
|
||||
'%%order_class%% .select2-container--default .select2-selection--single:hover',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text:hover',
|
||||
]
|
||||
),
|
||||
'focus_background_color' => implode(
|
||||
',',
|
||||
[
|
||||
'.woocommerce %%order_class%% .select2-container--open .select2-selection',
|
||||
'.woocommerce %%order_class%% form .input-text:focus',
|
||||
]
|
||||
),
|
||||
'focus_background_color_hover' => implode(
|
||||
',',
|
||||
[
|
||||
'.woocommerce %%order_class%% .select2-container--open:hover .select2-selection',
|
||||
'.woocommerce %%order_class%% form .input-text:focus:hover',
|
||||
]
|
||||
),
|
||||
'focus_text_color' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--open .select2-selection__rendered',
|
||||
'.woocommerce %%order_class%% form .form-row input.input-text:focus',
|
||||
)
|
||||
),
|
||||
'focus_text_color_hover' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--open:hover .select2-selection__rendered',
|
||||
'.woocommerce %%order_class%% form .form-row input.input-text:focus:hover',
|
||||
)
|
||||
),
|
||||
'form_text_color' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--default .select2-selection--single .select2-selection__rendered',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text',
|
||||
)
|
||||
),
|
||||
'form_text_color_hover' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container .select2-selection--single:hover .select2-selection__rendered',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text:hover',
|
||||
)
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% .select2-container--default .select2-selection--single',
|
||||
'%%order_class%% form .form-row input.input-text',
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
'border_styles' => array(
|
||||
'form_field' => array(
|
||||
'label_prefix' => esc_html__( 'Fields', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--default .select2-selection--single',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text',
|
||||
)
|
||||
),
|
||||
'border_radii' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--default .select2-selection--single',
|
||||
'.woocommerce %%order_class%% form .form-row input.input-text',
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'solid',
|
||||
),
|
||||
),
|
||||
),
|
||||
'form_field_focus' => array(
|
||||
'label_prefix' => esc_html__( 'Fields Focus', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--default.select2-container--open .select2-selection--single',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text:focus',
|
||||
)
|
||||
),
|
||||
'border_radii' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--default.select2-container--open .select2-selection--single',
|
||||
'.woocommerce %%order_class%% form .form-row input.input-text:focus',
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'solid',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'font_field' => array(
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
[
|
||||
'.woocommerce %%order_class%% .select2-container--default .select2-selection--single',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text',
|
||||
]
|
||||
),
|
||||
|
||||
// Required to override default WooCommerce styles.
|
||||
'important' => array( 'line-height', 'size', 'font' ),
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.7em',
|
||||
),
|
||||
),
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% form .form-row input.input-text, %%order_class%% .select2-container--default .select2-selection--single .select2-selection__rendered',
|
||||
'padding' => '%%order_class%% form .form-row input.input-text, %%order_class%% .select2-container--default .select2-selection--single',
|
||||
'margin' => '%%order_class%% form .form-row input.input-text, %%order_class%% .select2-container--default .select2-selection--single',
|
||||
),
|
||||
),
|
||||
'width' => array(),
|
||||
'toggle_priority' => 55,
|
||||
),
|
||||
'form_notice' => array(
|
||||
'label' => esc_html__( 'Form Notice', 'et_builder' ),
|
||||
'css' => array(
|
||||
'form_text_color' => '%%order_class%% .woocommerce-error li',
|
||||
'background_color' => '%%order_class%% .woocommerce-error',
|
||||
'important' => array( 'background_color' ),
|
||||
),
|
||||
'background_color' => array(
|
||||
'description' => esc_html__( 'Pick a color to fill the module\'s notice.', 'et_builder' ),
|
||||
),
|
||||
'text_color' => array(
|
||||
'description' => esc_html__( 'Pick a color to be used for the text written inside notice.', 'et_builder' ),
|
||||
),
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'font_field' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% .woocommerce-NoticeGroup .woocommerce-error',
|
||||
'important' => array( 'text-shadow', 'size' ),
|
||||
'text_shadow' => '%%order_class%% .woocommerce-NoticeGroup .woocommerce-error',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '18px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.7em',
|
||||
),
|
||||
),
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% .woocommerce-error',
|
||||
'important' => array( 'custom_padding' ),
|
||||
),
|
||||
'custom_padding' => array(
|
||||
'default' => '15px|15px|15px|15px|false|false',
|
||||
),
|
||||
),
|
||||
'border_styles' => array(
|
||||
'form_notice' => array(
|
||||
'label_prefix' => esc_html__( 'Form Notice', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% .woocommerce-error',
|
||||
'border_radii' => '%%order_class%% .woocommerce-error',
|
||||
),
|
||||
'important' => true,
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'solid',
|
||||
),
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% .woocommerce-error',
|
||||
'important' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->custom_css_fields = array(
|
||||
'title_text' => array(
|
||||
'label' => esc_html__( 'Title Text', 'et_builder' ),
|
||||
'selector' => '%%order_class%% h3',
|
||||
),
|
||||
'field_label' => array(
|
||||
'label' => esc_html__( 'Field Label', 'et_builder' ),
|
||||
'selector' => '%%order_class%% form .form-row label',
|
||||
),
|
||||
'form_field' => array(
|
||||
'label' => esc_html__( 'Fields', 'et_builder' ),
|
||||
'selector' => implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% .select2-container--default .select2-selection--single',
|
||||
'%%order_class%% form .form-row .input-text',
|
||||
)
|
||||
),
|
||||
),
|
||||
'form_notice' => array(
|
||||
'label' => esc_html__( 'Form Notice', 'et_builder' ),
|
||||
'selector' => '%%order_class%% .woocommerce-error',
|
||||
),
|
||||
);
|
||||
|
||||
$this->help_videos = array(
|
||||
array(
|
||||
'id' => esc_html( '7X03vBPYJ1o' ),
|
||||
'name' => esc_html__( 'Divi WooCommerce Modules', 'et_builder' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_fields() {
|
||||
$fields = array(
|
||||
'required_field_indicator_color' => array(
|
||||
'label' => esc_html__(
|
||||
'Required Field Indicator Color',
|
||||
'et_builder'
|
||||
),
|
||||
'description' => esc_html__(
|
||||
'Pick a color to be used for the required field indicator.',
|
||||
'et_builder'
|
||||
),
|
||||
'type' => 'color-alpha',
|
||||
'option_category' => 'button',
|
||||
'custom_color' => true,
|
||||
'default' => '',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'field_label',
|
||||
'hover' => 'tabs',
|
||||
'mobile_options' => true,
|
||||
'priority' => 5,
|
||||
),
|
||||
'fields_width' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'fields_width'
|
||||
),
|
||||
'__checkout_billing' => array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Billing',
|
||||
'get_checkout_billing',
|
||||
),
|
||||
'computed_depends_on' => array(
|
||||
|
||||
/*
|
||||
* `depends_on` arg is required. Otherwise AJAX will return null.
|
||||
* @see et_pb_process_computed_property().
|
||||
* `product` will not be processed since there is no definition in
|
||||
* @see ET_Builder_Module_Woocommerce_Checkout_Order::get_fields()
|
||||
*/
|
||||
'product',
|
||||
),
|
||||
),
|
||||
'placeholder_color' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'placeholder_color'
|
||||
),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_transition_fields_css_props() {
|
||||
$fields = parent::get_transition_fields_css_props();
|
||||
|
||||
$fields['required_field_indicator_color'] = array(
|
||||
'color' => '%%order_class%% form .form-row .required',
|
||||
);
|
||||
$fields['placeholder_color'] = array(
|
||||
'color' => array(
|
||||
'%%order_class%% form .input-text::placeholder',
|
||||
'%%order_class%% form .input-text::-webkit-input-placeholder',
|
||||
'%%order_class%% form .input-text::-moz-placeholder',
|
||||
'%%order_class%% form .input-text:-ms-input-placeholder',
|
||||
),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps Checkout Order Details template.
|
||||
*
|
||||
* Coupon Remove Link must be shown in VB. Hence we swap the template.
|
||||
*
|
||||
* @param string $template Template.
|
||||
* @param string $template_name Template name.
|
||||
* @param array $args Arguments.
|
||||
* @param string $template_path Template path.
|
||||
* @param string $default_path Default path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function swap_template( $template, $template_name, $args, $template_path, $default_path ) {
|
||||
$is_template_override = in_array(
|
||||
$template_name,
|
||||
array(
|
||||
'checkout/form-checkout.php',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
if ( $is_template_override ) {
|
||||
return trailingslashit( ET_BUILDER_DIR ) . 'feature/woocommerce/templates/' . $template_name;
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset hooks.
|
||||
*
|
||||
* @since 4.14.8 $conditional_tags param added.
|
||||
*
|
||||
* @param array $conditional_tags List of conditional tags.
|
||||
*/
|
||||
public static function maybe_reset_hooks( $conditional_tags ) {
|
||||
$is_tb = et_()->array_get( $conditional_tags, 'is_tb', false );
|
||||
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_coupon_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_login_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_order_review();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_payment();
|
||||
|
||||
if ( ! et_fb_is_computed_callback_ajax() && ! $is_tb ) {
|
||||
remove_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Billing',
|
||||
'swap_template',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
}
|
||||
|
||||
add_action(
|
||||
'woocommerce_checkout_shipping',
|
||||
[
|
||||
WC_Checkout::instance(),
|
||||
'checkout_form_shipping',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle hooks.
|
||||
*
|
||||
* @since 4.14.8 $conditional_tags param added.
|
||||
*
|
||||
* @param array $conditional_tags List of conditional tags.
|
||||
*/
|
||||
public static function maybe_handle_hooks( $conditional_tags = array() ) {
|
||||
$is_tb = et_()->array_get( $conditional_tags, 'is_tb', false );
|
||||
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_coupon_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_login_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_order_review();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_payment();
|
||||
|
||||
if ( ! et_fb_is_computed_callback_ajax() && ! $is_tb ) {
|
||||
add_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Billing',
|
||||
'swap_template',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
}
|
||||
|
||||
remove_action(
|
||||
'woocommerce_checkout_shipping',
|
||||
[
|
||||
WC_Checkout::instance(),
|
||||
'checkout_form_shipping',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Billing markup.
|
||||
*
|
||||
* @param array $args List of Shortcode attributes.
|
||||
* @param array $conditional_tags List of conditional tags.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_checkout_billing( $args = array(), $conditional_tags = array() ) {
|
||||
if ( ! class_exists( 'WC_Shortcode_Checkout' ) ||
|
||||
! method_exists( 'WC_Shortcode_Checkout', 'output' ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
self::maybe_handle_hooks( $conditional_tags );
|
||||
|
||||
$is_cart_empty = function_exists( 'WC' ) && isset( WC()->cart ) && WC()->cart->is_empty();
|
||||
$is_pb_mode = et_fb_is_computed_callback_ajax() || is_et_pb_preview();
|
||||
$class = 'ET_Builder_Module_Helper_Woocommerce_Modules';
|
||||
|
||||
// Set dummy cart contents to output Billing when no product is in cart.
|
||||
if ( ( $is_cart_empty && $is_pb_mode ) || is_et_pb_preview() ) {
|
||||
add_filter(
|
||||
'woocommerce_get_cart_contents',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
array( $class, 'set_dummy_cart_contents' )
|
||||
);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
WC_Shortcode_Checkout::output( array() );
|
||||
|
||||
$markup = ob_get_clean();
|
||||
|
||||
if ( ( $is_cart_empty && $is_pb_mode ) || is_et_pb_preview() ) {
|
||||
remove_filter(
|
||||
'woocommerce_get_cart_contents',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
array( $class, 'set_dummy_cart_contents' )
|
||||
);
|
||||
}
|
||||
|
||||
self::maybe_reset_hooks( $conditional_tags );
|
||||
|
||||
// Fallback.
|
||||
if ( ! is_string( $markup ) ) {
|
||||
$markup = '';
|
||||
}
|
||||
|
||||
return $markup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the module output.
|
||||
*
|
||||
* @param array $attrs List of attributes.
|
||||
* @param string $content Content being processed.
|
||||
* @param string $render_slug Slug of module that is used for rendering output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render( $attrs, $content, $render_slug ) {
|
||||
if ( function_exists( 'is_order_received_page' )
|
||||
&& is_order_received_page() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$output = self::get_checkout_billing();
|
||||
|
||||
$fields_width = et_()->array_get( $this->props, 'fields_width', false );
|
||||
if ( false !== $fields_width ) {
|
||||
$this->add_classname( "et_pb_fields_layout_{$fields_width}" );
|
||||
}
|
||||
|
||||
// Handle Required Field Indicator Color responsive and hover fields.
|
||||
$required_field_indicator_color_values = et_pb_responsive_options()->get_property_values( $this->props, 'required_field_indicator_color' );
|
||||
$required_field_indicator_color_hover = $this->get_hover_value( 'required_field_indicator_color' );
|
||||
$required_field_indicator_selector = '%%order_class%% form .form-row .required';
|
||||
|
||||
et_pb_responsive_options()->generate_responsive_css(
|
||||
$required_field_indicator_color_values,
|
||||
$required_field_indicator_selector,
|
||||
'color',
|
||||
$render_slug,
|
||||
' !important;',
|
||||
'color'
|
||||
);
|
||||
|
||||
// Placeholder Color.
|
||||
$placeholder_selectors = array(
|
||||
'%%order_class%% form .form-row input.input-text::placeholder',
|
||||
'%%order_class%% form .form-row input.input-text::-webkit-input-placeholder',
|
||||
'%%order_class%% form .form-row input.input-text::-moz-placeholder',
|
||||
'%%order_class%% form .form-row input.input-text:-ms-input-placeholder',
|
||||
);
|
||||
|
||||
$this->generate_styles(
|
||||
array(
|
||||
'base_attr_name' => 'placeholder_color',
|
||||
'selector' => join( ', ', $placeholder_selectors ),
|
||||
'hover_pseudo_selector_location' => 'suffix',
|
||||
'sticky_pseudo_selector_location' => 'prefix',
|
||||
'css_property' => 'color',
|
||||
'important' => false,
|
||||
'render_slug' => $render_slug,
|
||||
'type' => 'color',
|
||||
)
|
||||
);
|
||||
|
||||
if ( et_builder_is_hover_enabled( 'required_field_indicator_color', $this->props ) ) {
|
||||
ET_Builder_Element::set_style(
|
||||
$render_slug,
|
||||
array(
|
||||
'selector' => '%%order_class%% form .form-row:hover .required',
|
||||
'declaration' => sprintf(
|
||||
'color: %1$s;',
|
||||
esc_html( $required_field_indicator_color_hover )
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->add_classname( $this->get_text_orientation_classname() );
|
||||
|
||||
global $wp;
|
||||
if ( ! empty( $wp->query_vars['order-pay'] ) ) {
|
||||
$this->add_classname( 'et_pb_wc_order_pay' );
|
||||
}
|
||||
|
||||
if ( isset( WC()->cart )
|
||||
&& ! is_null( WC()->cart && method_exists( WC()->cart, 'check_cart_items' ) )
|
||||
&& ! is_et_pb_preview() ) {
|
||||
$return = WC()->cart->check_cart_items();
|
||||
|
||||
if ( wc_notice_count( 'error' ) > 0 ) {
|
||||
$this->add_classname( 'et_pb_hide_module' );
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_render_module_wrapper( $output, $render_slug );
|
||||
}
|
||||
}
|
||||
|
||||
new ET_Builder_Module_Woocommerce_Checkout_Billing();
|
678
includes/builder/module/woocommerce/CheckoutOrderDetails.php
Normal file
678
includes/builder/module/woocommerce/CheckoutOrderDetails.php
Normal file
@ -0,0 +1,678 @@
|
||||
<?php
|
||||
/**
|
||||
* WooCommerce Modules: ET_Builder_Module_Woocommerce_Checkout_Order_Details class
|
||||
*
|
||||
* The ET_Builder_Module_Woocommerce_Checkout_Order_Details Class is responsible for rendering the
|
||||
* Checkout order details section using the WooCommerce template.
|
||||
*
|
||||
* @package Divi\Builder
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing Woo Checkout Details component.
|
||||
*/
|
||||
class ET_Builder_Module_Woocommerce_Checkout_Order_Details extends ET_Builder_Module {
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Checkout Details', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Checkout Details', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_checkout_order_details';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'title' => array(
|
||||
'title' => esc_html__( 'Title Text', 'et_builder' ),
|
||||
'priority' => 55,
|
||||
),
|
||||
'column_label' => array(
|
||||
'title' => esc_html__( 'Column Label', 'et_builder' ),
|
||||
'priority' => 60,
|
||||
),
|
||||
'body' => array(
|
||||
'title' => esc_html__( 'Body Text', 'et_builder' ),
|
||||
'tabbed_subtoggles' => true,
|
||||
'sub_toggles' => array(
|
||||
'p' => array(
|
||||
'name' => 'P',
|
||||
'icon' => 'text-left',
|
||||
),
|
||||
'a' => array(
|
||||
'name' => 'A',
|
||||
'icon' => 'text-link',
|
||||
),
|
||||
),
|
||||
'priority' => 65,
|
||||
),
|
||||
'table' => array(
|
||||
'title' => esc_html__( 'Table', 'et_builder' ),
|
||||
'priority' => 70,
|
||||
),
|
||||
'table_row' => array(
|
||||
'title' => esc_html__( 'Table Row', 'et_builder' ),
|
||||
'priority' => 75,
|
||||
),
|
||||
'table_cell' => array(
|
||||
'title' => esc_html__( 'Table Cell', 'et_builder' ),
|
||||
'priority' => 80,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->advanced_fields = array(
|
||||
'fonts' => array(
|
||||
'title' => array(
|
||||
'label' => esc_html__( 'Title', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #order_review_heading',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '22px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1em',
|
||||
),
|
||||
),
|
||||
'column_label' => array(
|
||||
'label' => esc_html__( 'Column Label', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_table thead th',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.5em',
|
||||
),
|
||||
),
|
||||
'body' => array(
|
||||
'label' => esc_html__( 'Body', 'et_builder' ),
|
||||
'css' => array(
|
||||
|
||||
// Accepts only string and not array. Hence using `implode`.
|
||||
'main' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% td',
|
||||
'%%order_class%% tfoot th',
|
||||
)
|
||||
),
|
||||
|
||||
// Accepts only string and not array. Hence using `implode`.
|
||||
'line_height' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_table th',
|
||||
'%%order_class%% table.shop_table td',
|
||||
)
|
||||
),
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.5em',
|
||||
),
|
||||
'toggle_slug' => 'body',
|
||||
'sub_toggle' => 'p',
|
||||
),
|
||||
'link' => array(
|
||||
'label' => esc_html__( 'Link', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% td a',
|
||||
'line_height' => '%%order_class%% td a',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.5em',
|
||||
),
|
||||
'toggle_slug' => 'body',
|
||||
'sub_toggle' => 'a',
|
||||
),
|
||||
),
|
||||
'text' => array(
|
||||
'css' => array(
|
||||
'text_orientation' => '%%order_class%% h3, table.shop_table th, table.shop_table tr td',
|
||||
// Refer ET_Builder_Module_Field_TextShadow::update_styles for selector
|
||||
// definition.
|
||||
'text_shadow' => '%%order_class%% h3, table.shop_table th, table.shop_table tr td',
|
||||
),
|
||||
),
|
||||
'link_options' => false,
|
||||
'form_field' => array(
|
||||
'table' => array(
|
||||
'label' => esc_html__( 'Table', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_table',
|
||||
),
|
||||
'background_color' => array(
|
||||
'description' => esc_html__( 'Pick a color to fill the module\'s table.', 'et_builder' ),
|
||||
),
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_table',
|
||||
'important' => array( 'custom_margin' ),
|
||||
),
|
||||
'depends_on' => array(
|
||||
'collapse_table_gutters_borders',
|
||||
),
|
||||
'depends_show_if' => 'off',
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'table' => array(
|
||||
'label_prefix' => esc_html__( 'Table', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% table.shop_table',
|
||||
'border_radii' => '%%order_class%% table.shop_table',
|
||||
),
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|5px|5px|5px|5px',
|
||||
'border_styles' => array(
|
||||
'width' => '1px',
|
||||
),
|
||||
),
|
||||
'depends_on' => array(
|
||||
'collapse_table_gutters_borders',
|
||||
),
|
||||
'depends_show_if' => 'off',
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_table',
|
||||
),
|
||||
),
|
||||
),
|
||||
'table_row' => array(
|
||||
'label' => esc_html__( 'Table Row', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_table tr',
|
||||
),
|
||||
'background_color' => array(
|
||||
'description' => esc_html__( 'Pick a color to fill the module\'s table row.', 'et_builder' ),
|
||||
),
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_table tr th, %%order_class%% table.shop_table tr td',
|
||||
),
|
||||
'use_margin' => false,
|
||||
'use_padding' => false,
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'table_row' => array(
|
||||
'label_prefix' => esc_html__( 'Table Row', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
|
||||
// Accepts only string and not array. Hence using `implode`.
|
||||
'border_radii' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_table th',
|
||||
'%%order_class%% table.shop_table td',
|
||||
)
|
||||
),
|
||||
'border_styles' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_table th',
|
||||
'%%order_class%% table.shop_table td',
|
||||
)
|
||||
),
|
||||
),
|
||||
'important' => true,
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '1px',
|
||||
),
|
||||
),
|
||||
'depends_on' => array(
|
||||
'collapse_table_gutters_borders',
|
||||
),
|
||||
'depends_show_if' => 'on',
|
||||
'use_radius' => false,
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_table tr',
|
||||
),
|
||||
),
|
||||
),
|
||||
'table_cell' => array(
|
||||
'label' => esc_html__( 'Table Cell', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_table tr th, %%order_class%% table.shop_table tr td',
|
||||
),
|
||||
'background_color' => array(
|
||||
'description' => esc_html__( 'Pick a color to fill the module\'s table cell.', 'et_builder' ),
|
||||
),
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_table tr th',
|
||||
'%%order_class%% table.shop_table tr td',
|
||||
)
|
||||
),
|
||||
),
|
||||
'use_margin' => false,
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'table_cell' => array(
|
||||
'label_prefix' => esc_html__( 'Table Cell', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% table.shop_table tr th,%%order_class%% table.shop_table tr td',
|
||||
'border_radii' => '%%order_class%% table.shop_table tr th, %%order_class%% table.shop_table tr td',
|
||||
),
|
||||
'important' => array( 'border-color' ),
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'solid',
|
||||
),
|
||||
'composite' => array(
|
||||
'border_top' => array(
|
||||
'border_width_top' => '1px',
|
||||
'border_style_top' => 'solid',
|
||||
'border_color_top' => '#eeeeee',
|
||||
),
|
||||
),
|
||||
),
|
||||
'depends_on' => array(
|
||||
'collapse_table_gutters_borders',
|
||||
),
|
||||
'depends_show_if' => 'off',
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_table tr th, %%order_class%% table.shop_table td',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Use !important in Spacing OG — Margin values.
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'important' => array( 'custom_margin' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->custom_css_fields = array(
|
||||
'title_text' => array(
|
||||
'label' => esc_html__( 'Title Text', 'et_builder' ),
|
||||
'selector' => '%%order_class%% h1, %%order_class%% h2, %%order_class%% h3, %%order_class%% h4, %%order_class%% h5, %%order_class%% h6',
|
||||
),
|
||||
);
|
||||
|
||||
$this->help_videos = array(
|
||||
array(
|
||||
'id' => esc_html( '7X03vBPYJ1o' ),
|
||||
'name' => esc_html__( 'Divi WooCommerce Modules', 'et_builder' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_fields() {
|
||||
$fields = array(
|
||||
'__checkout_order_details' => array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Order_Details',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- This is a function call.
|
||||
'get_checkout_order_details'
|
||||
),
|
||||
'computed_depends_on' => array(
|
||||
|
||||
/*
|
||||
* `depends_on` arg is required. Otherwise AJAX will return null.
|
||||
* @see et_pb_process_computed_property().
|
||||
* `product` will not be processed since there is no definition in
|
||||
* @see ET_Builder_Module_Woocommerce_Checkout_Order::get_fields()
|
||||
*/
|
||||
'product',
|
||||
),
|
||||
),
|
||||
'collapse_table_gutters_borders' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field( 'collapse_table_gutters_borders' ),
|
||||
'vertical_gutter_width' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field( 'vertical_gutter_width' ),
|
||||
'horizontal_gutter_width' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field( 'horizontal_gutter_width' ),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps Checkout Order Details template.
|
||||
*
|
||||
* Coupon Remove Link must be shown in VB. Hence we swap the template.
|
||||
*
|
||||
* @param string $template Template.
|
||||
* @param string $template_name Template name.
|
||||
* @param array $args Arguments.
|
||||
* @param string $template_path Template path.
|
||||
* @param string $default_path Default path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function swap_template_fe( $template, $template_name, $args, $template_path, $default_path ) {
|
||||
$is_template_override = in_array(
|
||||
$template_name,
|
||||
array(
|
||||
'checkout/form-checkout.php',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
if ( $is_template_override ) {
|
||||
return trailingslashit( ET_BUILDER_DIR ) . 'feature/woocommerce/templates/' . $template_name;
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps Checkout Order Details template.
|
||||
*
|
||||
* Coupon Remove Link must be shown in VB. Hence we swap the template.
|
||||
*
|
||||
* @param string $template Template.
|
||||
* @param string $template_name Template name.
|
||||
* @param array $args Arguments.
|
||||
* @param string $template_path Template path.
|
||||
* @param string $default_path Default path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function swap_template( $template, $template_name, $args, $template_path, $default_path ) {
|
||||
$is_template_override = in_array(
|
||||
$template_name,
|
||||
array(
|
||||
'checkout/review-order.php',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
if ( $is_template_override ) {
|
||||
return trailingslashit( ET_BUILDER_DIR ) . 'feature/woocommerce/templates/' . $template_name;
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset hooks.
|
||||
*
|
||||
* @param array $conditional_tags Array of conditional tags.
|
||||
*/
|
||||
public static function maybe_reset_hooks( $conditional_tags ) {
|
||||
$is_tb = et_()->array_get( $conditional_tags, 'is_tb', false );
|
||||
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_coupon_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_login_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_billing();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_shipping();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_payment();
|
||||
|
||||
if ( et_fb_is_computed_callback_ajax() || $is_tb ) {
|
||||
remove_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Order_Details',
|
||||
'swap_template',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! et_fb_is_computed_callback_ajax() && ! $is_tb ) {
|
||||
remove_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Order_Details',
|
||||
'swap_template_fe',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle hooks.
|
||||
*
|
||||
* @param array $conditional_tags Array of conditional tags.
|
||||
*/
|
||||
public static function maybe_handle_hooks( $conditional_tags ) {
|
||||
$is_tb = et_()->array_get( $conditional_tags, 'is_tb', false );
|
||||
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_coupon_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_login_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_billing();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_shipping();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_payment();
|
||||
|
||||
if ( et_fb_is_computed_callback_ajax() || $is_tb ) {
|
||||
add_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Order_Details',
|
||||
'swap_template',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! et_fb_is_computed_callback_ajax() && ! $is_tb ) {
|
||||
add_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Order_Details',
|
||||
'swap_template_fe',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Checkout Order Details markup.
|
||||
*
|
||||
* @param array $args Array of `depends_on` key/value pairs.
|
||||
* @param array $conditional_tags Array of conditional tags.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_checkout_order_details( $args = array(), $conditional_tags = array() ) {
|
||||
if ( ! class_exists( 'WC_Shortcode_Checkout' )
|
||||
|| ! method_exists( 'WC_Shortcode_Checkout', 'output' ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
self::maybe_handle_hooks( $conditional_tags );
|
||||
|
||||
$is_cart_empty = function_exists( 'WC' ) && isset( WC()->cart ) && WC()->cart->is_empty();
|
||||
$is_pb_mode = et_fb_is_computed_callback_ajax() || is_et_pb_preview();
|
||||
$class = 'ET_Builder_Module_Helper_Woocommerce_Modules';
|
||||
|
||||
// Set dummy cart contents to output Billing when no product is in cart.
|
||||
if ( ( $is_cart_empty && $is_pb_mode ) || is_et_pb_preview() ) {
|
||||
add_filter(
|
||||
'woocommerce_get_cart_contents',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- This is a function call.
|
||||
array( $class, 'set_dummy_cart_contents' )
|
||||
);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
WC_Shortcode_Checkout::output( array() );
|
||||
|
||||
$markup = ob_get_clean();
|
||||
|
||||
if ( ( $is_cart_empty && $is_pb_mode ) || is_et_pb_preview() ) {
|
||||
remove_filter(
|
||||
'woocommerce_get_cart_contents',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- This is a function call.
|
||||
array( $class, 'set_dummy_cart_contents' )
|
||||
);
|
||||
}
|
||||
|
||||
self::maybe_reset_hooks( $conditional_tags );
|
||||
|
||||
// Fallback.
|
||||
if ( ! is_string( $markup ) ) {
|
||||
$markup = '';
|
||||
}
|
||||
|
||||
return $markup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the module output.
|
||||
*
|
||||
* @param array $attrs List of attributes.
|
||||
* @param string $content Content being processed.
|
||||
* @param string $render_slug Slug of module that is used for rendering output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render( $attrs, $content, $render_slug ) {
|
||||
if ( function_exists( 'is_order_received_page' )
|
||||
&& is_order_received_page() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->add_classname( $this->get_text_orientation_classname() );
|
||||
|
||||
$output = self::get_checkout_order_details();
|
||||
|
||||
$collapse_table_gutters_borders_style_values = array();
|
||||
$table_border_spacing_style_values = array();
|
||||
foreach ( et_pb_responsive_options()->get_modes() as $device ) {
|
||||
$collapse_table_gutters_borders = et_pb_responsive_options()->get_property_value(
|
||||
$attrs,
|
||||
'collapse_table_gutters_borders',
|
||||
'off',
|
||||
$device,
|
||||
true
|
||||
);
|
||||
|
||||
$horizontal_gutter_width_value = et_pb_responsive_options()->get_property_value(
|
||||
$attrs,
|
||||
'horizontal_gutter_width',
|
||||
'0px',
|
||||
$device,
|
||||
true
|
||||
);
|
||||
$vertical_gutter_width_value = et_pb_responsive_options()->get_property_value(
|
||||
$attrs,
|
||||
'vertical_gutter_width',
|
||||
'0px',
|
||||
$device,
|
||||
true
|
||||
);
|
||||
|
||||
if ( 'on' === $collapse_table_gutters_borders ) {
|
||||
$collapse_table_gutters_borders_style_values[ $device ] = array(
|
||||
'border-collapse' => 'collapse',
|
||||
);
|
||||
|
||||
$table_border_spacing_style_values[ $device ] = array(
|
||||
'border-spacing' => '0 0',
|
||||
);
|
||||
} else {
|
||||
$collapse_table_gutters_borders_style_values[ $device ] = array(
|
||||
'border-collapse' => 'separate',
|
||||
);
|
||||
|
||||
$table_border_spacing_style_values[ $device ] = array(
|
||||
'border-spacing' => sprintf(
|
||||
'%s %s',
|
||||
$horizontal_gutter_width_value,
|
||||
$vertical_gutter_width_value
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
et_pb_responsive_options()->generate_responsive_css(
|
||||
$collapse_table_gutters_borders_style_values,
|
||||
'%%order_class%% table.shop_table',
|
||||
'border-collapse',
|
||||
$render_slug,
|
||||
'',
|
||||
'border-collapse' /* Can be anything other than `range`. */
|
||||
);
|
||||
|
||||
et_pb_responsive_options()->generate_responsive_css(
|
||||
$table_border_spacing_style_values,
|
||||
'%%order_class%% table.shop_table',
|
||||
'border-spacing',
|
||||
$render_slug,
|
||||
'',
|
||||
'border-spacing' /* Can be anything other than `range`. */
|
||||
);
|
||||
|
||||
if ( isset( WC()->cart )
|
||||
&& ! is_null( WC()->cart && method_exists( WC()->cart, 'check_cart_items' ) )
|
||||
&& ! is_et_pb_preview() ) {
|
||||
$return = WC()->cart->check_cart_items();
|
||||
|
||||
if ( wc_notice_count( 'error' ) > 0 ) {
|
||||
$this->add_classname( 'et_pb_hide_module' );
|
||||
}
|
||||
}
|
||||
|
||||
global $wp;
|
||||
if ( ! empty( $wp->query_vars['order-pay'] ) ) {
|
||||
$this->add_classname( 'et_pb_wc_order_pay' );
|
||||
}
|
||||
|
||||
return $this->_render_module_wrapper( $output, $render_slug );
|
||||
}
|
||||
}
|
||||
|
||||
new ET_Builder_Module_Woocommerce_Checkout_Order_Details();
|
694
includes/builder/module/woocommerce/CheckoutPaymentInfo.php
Normal file
694
includes/builder/module/woocommerce/CheckoutPaymentInfo.php
Normal file
@ -0,0 +1,694 @@
|
||||
<?php
|
||||
/**
|
||||
* WooCommerce Modules: ET_Builder_Module_Woocommerce_Checkout_Payment_Info class
|
||||
*
|
||||
* The ET_Builder_Module_Woocommerce_Checkout_Payment_Info Class is responsible for rendering the
|
||||
* Checkout payment info using the WooCommerce template.
|
||||
*
|
||||
* @package Divi\Builder
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Checkout Payment component.
|
||||
*/
|
||||
class ET_Builder_Module_Woocommerce_Checkout_Payment_Info extends ET_Builder_Module {
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Checkout Payment', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Checkout Payment', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_checkout_payment_info';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->main_css_element = implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% .woocommerce-checkout #payment',
|
||||
'%%order_class%% .woocommerce-order',
|
||||
)
|
||||
);
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'body' => array(
|
||||
'title' => esc_html__( 'Body Text', 'et_builder' ),
|
||||
'tabbed_subtoggles' => true,
|
||||
'sub_toggles' => array(
|
||||
'p' => array(
|
||||
'name' => 'P',
|
||||
'icon' => 'text-left',
|
||||
),
|
||||
'a' => array(
|
||||
'name' => 'A',
|
||||
'icon' => 'text-link',
|
||||
),
|
||||
),
|
||||
'priority' => 52,
|
||||
),
|
||||
'radio_button' => array(
|
||||
'title' => esc_html__( 'Radio Buttons', 'et_builder' ),
|
||||
'priority' => 65,
|
||||
),
|
||||
'selected_radio_button' => array(
|
||||
'title' => esc_html__( 'Selected Radio Button', 'et_builder' ),
|
||||
'priority' => 70,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->advanced_fields = array(
|
||||
'fonts' => array(
|
||||
'body' => array(
|
||||
'label' => et_builder_i18n( 'Body' ),
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% .woocommerce-privacy-policy-text',
|
||||
'%%order_class%% .woocommerce-privacy-policy-text a',
|
||||
'%%order_class%% .wc_payment_method a',
|
||||
|
||||
// Order confirmation Page elements.
|
||||
'%%order_class%% .woocommerce-order p',
|
||||
'%%order_class%% .woocommerce-order .woocommerce-order-overview',
|
||||
)
|
||||
),
|
||||
'important' => array( 'size', 'line-height' ),
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.7em',
|
||||
),
|
||||
'toggle_slug' => 'body',
|
||||
'sub_toggle' => 'p',
|
||||
),
|
||||
'link' => array(
|
||||
'label' => et_builder_i18n( 'Link' ),
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% .woocommerce-privacy-policy-text a',
|
||||
'%%order_class%% .wc_payment_method a',
|
||||
)
|
||||
),
|
||||
// CPT style uses `!important` so outputting important is inevitable.
|
||||
'important' => 'all',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.7em',
|
||||
),
|
||||
'toggle_slug' => 'body',
|
||||
'sub_toggle' => 'a',
|
||||
),
|
||||
),
|
||||
'link_options' => false,
|
||||
'button' => array(
|
||||
'button' => array(
|
||||
'label' => esc_html__( 'Button', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment #place_order',
|
||||
),
|
||||
'use_alignment' => false,
|
||||
'border_width' => array(
|
||||
'default' => '2px',
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment #place_order',
|
||||
),
|
||||
),
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'important' => 'all',
|
||||
),
|
||||
),
|
||||
'toggle_priority' => 80,
|
||||
),
|
||||
),
|
||||
'form_field' => array(
|
||||
'radio_button' => array(
|
||||
'label' => esc_html__( 'Radio Button', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment .wc_payment_method',
|
||||
'text_shadow' => '%%order_class%% #payment .wc_payment_method label',
|
||||
),
|
||||
'background_color' => array(
|
||||
'description' => esc_html__( 'Pick a color to fill the module\'s radio buttons.', 'et_builder' ),
|
||||
),
|
||||
'text_color' => array(
|
||||
'description' => esc_html__( 'Pick a color to be used for the text written next to radio button.', 'et_builder' ),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment .wc_payment_method',
|
||||
),
|
||||
),
|
||||
'border_styles' => array(
|
||||
'radio_button' => array(
|
||||
'label_prefix' => esc_html__( 'Radio Button', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% #payment .wc_payment_method',
|
||||
'border_radii' => '%%order_class%% #payment .wc_payment_method',
|
||||
),
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'off|0px|0px|0px|0px',
|
||||
'border_style' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'none',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'font_field' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment .wc_payment_method label',
|
||||
'focus' => '%%order_class%% #payment .input-radio:focus',
|
||||
'text_align' => '%%order_class%% #payment ul.payment_methods li',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.4em',
|
||||
),
|
||||
),
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
// Different from main css selector for added specificity.
|
||||
'margin' => '%%order_class%% #payment ul.payment_methods li',
|
||||
'padding' => '%%order_class%% #payment ul.payment_methods li',
|
||||
),
|
||||
),
|
||||
'width' => array(),
|
||||
),
|
||||
'selected_radio_button' => array(
|
||||
'label' => esc_html__( 'Selected Radio Button', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment .wc_payment_method.et_pb_checked',
|
||||
'text_shadow' => '%%order_class%% #payment .wc_payment_method.et_pb_checked label',
|
||||
),
|
||||
'background_color' => array(
|
||||
'description' => esc_html__( 'Pick a color to fill the module\'s selected radio button.', 'et_builder' ),
|
||||
),
|
||||
'text_color' => array(
|
||||
'description' => esc_html__( 'Pick a color to be used for the text written next to selected radio button.', 'et_builder' ),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment .wc_payment_method.et_pb_checked',
|
||||
),
|
||||
),
|
||||
'border_styles' => array(
|
||||
'selected_radio_button' => array(
|
||||
'label_prefix' => esc_html__( 'Selected Radio Button', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% #payment .wc_payment_method.et_pb_checked',
|
||||
'border_radii' => '%%order_class%% #payment .wc_payment_method.et_pb_checked',
|
||||
),
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'off|0px|0px|0px|0px',
|
||||
'border_style' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'none',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'font_field' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment .wc_payment_method.et_pb_checked label',
|
||||
'focus' => '%%order_class%% #payment .wc_payment_method.et_pb_checked .input-radio:focus',
|
||||
'text_align' => '%%order_class%% #payment ul.payment_methods li.et_pb_checked',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.4em',
|
||||
),
|
||||
),
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
// Different from main css selector for added specificity.
|
||||
'margin' => '%%order_class%% #payment ul.payment_methods li.et_pb_checked',
|
||||
'padding' => '%%order_class%% #payment ul.payment_methods li.et_pb_checked',
|
||||
),
|
||||
),
|
||||
'width' => array(),
|
||||
),
|
||||
'tooltip' => array(
|
||||
'label' => esc_html__( 'Tooltip', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment div.payment_box',
|
||||
),
|
||||
'background_color' => array(
|
||||
'description' => esc_html__( 'Pick a color to fill the module\'s tooltip.', 'et_builder' ),
|
||||
),
|
||||
'font_field' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% .wc_payment_method p',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '',
|
||||
'allowed_values' => et_builder_get_acceptable_css_string_values( 'width' ),
|
||||
'allow_empty' => true,
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.5em',
|
||||
),
|
||||
'hide_text_color' => false,
|
||||
),
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment div.payment_box',
|
||||
),
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'tooltip' => array(
|
||||
'label_prefix' => 'Tooltip',
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% #payment div.payment_box',
|
||||
'border_radii' => '%%order_class%% #payment div.payment_box',
|
||||
),
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|2px|2px|2px|2px',
|
||||
),
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment div.payment_box',
|
||||
),
|
||||
),
|
||||
'toggle_priority' => 70,
|
||||
),
|
||||
'form_notice' => array(
|
||||
'label' => esc_html__( 'Form Notice', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment ul.payment_methods li.woocommerce-info',
|
||||
),
|
||||
'background_color' => array(
|
||||
'description' => esc_html__( 'Pick a color to fill the module\'s notice.', 'et_builder' ),
|
||||
),
|
||||
'font_field' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment ul.payment_methods li.woocommerce-notice',
|
||||
'important' => array( 'size', 'text-shadow' ),
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '18px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.7em',
|
||||
),
|
||||
'hide_text_color' => false,
|
||||
),
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment ul.payment_methods li.woocommerce-info',
|
||||
'important' => array( 'custom_padding' ),
|
||||
),
|
||||
'custom_padding' => array(
|
||||
'default' => '15px|15px|15px|15px|false|false',
|
||||
),
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'form_notice' => array(
|
||||
'label_prefix' => esc_html__( 'Notice', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% #payment ul.payment_methods li.woocommerce-info',
|
||||
'border_radii' => '%%order_class%% #payment ul.payment_methods li.woocommerce-info',
|
||||
),
|
||||
'important' => true,
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'solid',
|
||||
),
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% #payment ul.payment_methods li.woocommerce-info',
|
||||
'important' => true,
|
||||
),
|
||||
),
|
||||
'toggle_priority' => 75,
|
||||
),
|
||||
),
|
||||
'background' => array(
|
||||
'css' => array(
|
||||
// Backgrounds need to be applied to module wrapper.
|
||||
'main' => '%%order_class%%.et_pb_wc_checkout_payment_info',
|
||||
),
|
||||
'options' => array(
|
||||
'background_color' => array(
|
||||
'default' => '#ebe9eb',
|
||||
),
|
||||
),
|
||||
),
|
||||
'borders' => array(
|
||||
'default' => array(
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% .woocommerce-checkout #payment',
|
||||
'%%order_class%% .woocommerce-order',
|
||||
)
|
||||
),
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|5px|5px|5px|5px',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'solid',
|
||||
'color' => '#eee',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% .woocommerce-checkout #payment',
|
||||
'%%order_class%% .woocommerce-order',
|
||||
)
|
||||
),
|
||||
),
|
||||
'custom_padding' => array(
|
||||
'default' => '1em|1em|1em|1em|false|false',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->custom_css_fields = array(
|
||||
'fields' => array(
|
||||
'label' => esc_html__( 'Fields', 'et_builder' ),
|
||||
'selector' => '%%order_class%% #payment .input-radio',
|
||||
),
|
||||
'body' => array(
|
||||
'label' => esc_html__( 'Body', 'et_builder' ),
|
||||
'selector' => '%%order_class%% .woocommerce-privacy-policy-text',
|
||||
),
|
||||
'body_anchor' => array(
|
||||
'label' => esc_html__( 'Body Link', 'et_builder' ),
|
||||
'selector' => '%%order_class%% .woocommerce-privacy-policy-text a',
|
||||
),
|
||||
'button' => array(
|
||||
'label' => esc_html__( 'Button', 'et_builder' ),
|
||||
'selector' => '%%order_class%% #payment #place_order',
|
||||
),
|
||||
'tooltip' => array(
|
||||
'label' => esc_html__( 'Tooltip', 'et_builder' ),
|
||||
'selector' => '%%order_class%% #payment div.payment_box',
|
||||
),
|
||||
'form_notice' => array(
|
||||
'label' => esc_html__( 'Form Notice', 'et_builder' ),
|
||||
'selector' => '%%order_class%% #payment ul.payment_methods li.woocommerce-info',
|
||||
),
|
||||
);
|
||||
|
||||
$this->help_videos = array(
|
||||
array(
|
||||
'id' => esc_html( '7X03vBPYJ1o' ),
|
||||
'name' => esc_html__( 'Divi WooCommerce Modules', 'et_builder' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_fields() {
|
||||
$fields = array(
|
||||
'__checkout_payment_info' => array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Payment_Info',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- This is a function call.
|
||||
'get_checkout_payment_info'
|
||||
),
|
||||
'computed_depends_on' => array(
|
||||
|
||||
/*
|
||||
* `depends_on` arg is required. Otherwise AJAX will return null.
|
||||
* @see et_pb_process_computed_property().
|
||||
* `product` will not be processed since there is no definition in
|
||||
* @see ET_Builder_Module_Woocommerce_Checkout_Order::get_fields()
|
||||
*/
|
||||
'product',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Button classname.
|
||||
*
|
||||
* @used-by ET_Builder_Module_Helper_Woocommerce_Modules::add_custom_button_icons()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_button_classname() {
|
||||
return 'button';
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps login form template.
|
||||
*
|
||||
* By default WooCommerce displays these only when logged-out.
|
||||
* However these templates must be shown in VB when logged-in. Hence we use these templates.
|
||||
*
|
||||
* @param string $template Template.
|
||||
* @param string $template_name Template name.
|
||||
* @param array $args Arguments.
|
||||
* @param string $template_path Template path.
|
||||
* @param string $default_path Default path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function swap_template( $template, $template_name, $args, $template_path, $default_path ) {
|
||||
$is_template_override = in_array(
|
||||
$template_name,
|
||||
array(
|
||||
'checkout/payment.php',
|
||||
'checkout/payment-method.php',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
if ( $is_template_override ) {
|
||||
return trailingslashit( ET_BUILDER_DIR ) . 'feature/woocommerce/templates/' . $template_name;
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset hooks.
|
||||
*/
|
||||
public static function maybe_reset_hooks() {
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_coupon_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_login_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_billing();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_shipping();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_order_review();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle hooks.
|
||||
*/
|
||||
public static function maybe_handle_hooks() {
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_coupon_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_login_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_billing();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_shipping();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_order_review();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Checkout Payment info markup.
|
||||
*
|
||||
* @param array $args Additional arguments.
|
||||
* @param array $conditional_tags Array of conditional tags.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_checkout_payment_info( $args = array(), $conditional_tags = array() ) {
|
||||
if ( ! class_exists( 'WC_Shortcode_Checkout' )
|
||||
|| ! method_exists( 'WC_Shortcode_Checkout', 'output' ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$is_tb = et_()->array_get( $conditional_tags, 'is_tb', false );
|
||||
|
||||
self::maybe_handle_hooks();
|
||||
|
||||
$is_cart_empty = function_exists( 'WC' ) && isset( WC()->cart ) && WC()->cart->is_empty();
|
||||
$is_pb_mode = et_fb_is_computed_callback_ajax() || is_et_pb_preview();
|
||||
$class = 'ET_Builder_Module_Helper_Woocommerce_Modules';
|
||||
|
||||
// Set dummy cart contents to output Billing when no product is in cart.
|
||||
if ( ( $is_cart_empty && $is_pb_mode ) || is_et_pb_preview() ) {
|
||||
add_filter(
|
||||
'woocommerce_get_cart_contents',
|
||||
array( $class, 'set_dummy_cart_contents' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( et_fb_is_computed_callback_ajax() || $is_tb || is_et_pb_preview() ) {
|
||||
/*
|
||||
* Show Login form in VB.
|
||||
*
|
||||
* The swapped login form will display irrespective of the user logged-in status.
|
||||
*
|
||||
* Previously swapped template (FE) will only display the form when
|
||||
* a user is not logged-in. Hence we use a different template in VB.
|
||||
*/
|
||||
add_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Payment_Info',
|
||||
'swap_template',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
if ( is_et_pb_preview() ) {
|
||||
printf(
|
||||
'<div className="et_pb_wc_inactive__message">%s</div>',
|
||||
esc_html__( 'Woo Checkout Payment module can be used on a page and cannot be previewd.', 'et_builder' )
|
||||
);
|
||||
} else {
|
||||
WC_Shortcode_Checkout::output( array() );
|
||||
}
|
||||
$markup = ob_get_clean();
|
||||
|
||||
if ( et_fb_is_computed_callback_ajax() || $is_tb || is_et_pb_preview() ) {
|
||||
remove_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Payment_Info',
|
||||
'swap_template',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
}
|
||||
|
||||
if ( ( $is_cart_empty && $is_pb_mode ) || is_et_pb_preview() ) {
|
||||
remove_filter(
|
||||
'woocommerce_get_cart_contents',
|
||||
array( $class, 'set_dummy_cart_contents' )
|
||||
);
|
||||
}
|
||||
|
||||
self::maybe_reset_hooks();
|
||||
|
||||
// Fallback.
|
||||
if ( ! is_string( $markup ) ) {
|
||||
$markup = '';
|
||||
}
|
||||
|
||||
return $markup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the module output.
|
||||
*
|
||||
* @param array $attrs List of attributes.
|
||||
* @param string $content Content being processed.
|
||||
* @param string $render_slug Slug of module that is used for rendering output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render( $attrs, $content, $render_slug ) {
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::process_custom_button_icons( $render_slug, $this );
|
||||
// Module classname.
|
||||
$this->add_classname( $this->get_text_orientation_classname() );
|
||||
|
||||
if ( $this->_module_has_background() ) {
|
||||
ET_Builder_Element::set_style(
|
||||
$render_slug,
|
||||
array(
|
||||
'selector' => '%%order_class%% .woocommerce-checkout #payment, %%order_class%% .woocommerce-order',
|
||||
'declaration' => 'background: transparent !important;',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$output = self::get_checkout_payment_info( $attrs );
|
||||
|
||||
return $this->_render_module_wrapper( $output, $render_slug );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if module has background.
|
||||
*
|
||||
* @since 4.15.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _module_has_background() {
|
||||
$has_background_color = ! empty( $this->props['background_color'] );
|
||||
$has_background_gradient = isset( $this->props['use_background_color_gradient'] ) && 'on' === $this->props['use_background_color_gradient'];
|
||||
$has_background_image = ! empty( $this->props['background_image'] );
|
||||
$has_background_video_mp4 = ! empty( $this->props['background_video_mp4'] );
|
||||
$has_background_video_webm = ! empty( $this->props['background_video_webm'] );
|
||||
$has_background_pattern = isset( $this->props['background_enable_pattern_style'] ) && 'on' === $this->props['background_enable_pattern_style'] && ! empty( $this->props['background_pattern_style'] );
|
||||
$has_background_mask = isset( $this->props['background_enable_pattern_style'] ) && 'on' === $this->props['background_enable_mask_style'] && ! empty( $this->props['background_mask_style'] );
|
||||
|
||||
return $has_background_color
|
||||
|| $has_background_gradient
|
||||
|| $has_background_image
|
||||
|| $has_background_video_mp4
|
||||
|| $has_background_video_webm
|
||||
|| $has_background_pattern
|
||||
|| $has_background_mask;
|
||||
}
|
||||
}
|
||||
|
||||
new ET_Builder_Module_Woocommerce_Checkout_Payment_Info();
|
595
includes/builder/module/woocommerce/CheckoutShipping.php
Normal file
595
includes/builder/module/woocommerce/CheckoutShipping.php
Normal file
@ -0,0 +1,595 @@
|
||||
<?php
|
||||
/**
|
||||
* WooCommerce Modules: ET_Builder_Module_Woocommerce_Checkout_Shipping class
|
||||
*
|
||||
* The ET_Builder_Module_Woocommerce_Checkout_Shipping Class is responsible for rendering the
|
||||
* Checkout shipping section using the WooCommerce template.
|
||||
*
|
||||
* @package Divi\Builder
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Checkout shipping component.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
class ET_Builder_Module_Woocommerce_Checkout_Shipping extends ET_Builder_Module {
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Checkout Shipping', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Checkout Shipping', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_checkout_shipping';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'layout' => array(
|
||||
'title' => et_builder_i18n( 'Layout' ),
|
||||
'priority' => 45,
|
||||
),
|
||||
'title' => array(
|
||||
'title' => esc_html__( 'Title Text', 'et_builder' ),
|
||||
'priority' => 55,
|
||||
),
|
||||
'field_label' => array(
|
||||
'title' => esc_html__( 'Field Labels', 'et_builder' ),
|
||||
'priority' => 60,
|
||||
),
|
||||
'form_field' => array(
|
||||
'title' => esc_html__( 'Fields', 'et_builder' ),
|
||||
'priority' => 65,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->advanced_fields = array(
|
||||
'fonts' => array(
|
||||
// Use `title` in place of `header` since `header` needs a workaround in Copy/Paste.
|
||||
'title' => array(
|
||||
'label' => esc_html__( 'Title', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% h3',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '22px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1em',
|
||||
),
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'title',
|
||||
),
|
||||
'field_label' => array(
|
||||
'label' => esc_html__( 'Field Label', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% form .form-row label',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '2em',
|
||||
),
|
||||
'toggle_slug' => 'field_label',
|
||||
),
|
||||
),
|
||||
'text' => array(
|
||||
'use_background_layout' => false,
|
||||
'use_text_orientation' => true,
|
||||
),
|
||||
'button' => false,
|
||||
'link_options' => false,
|
||||
'form_field' => array(
|
||||
'form_field' => array(
|
||||
'label' => esc_html__( 'Fields', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--default .select2-selection--single',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text',
|
||||
)
|
||||
),
|
||||
'background_color_hover' => implode(
|
||||
',',
|
||||
[
|
||||
'%%order_class%% .select2-container--default .select2-selection--single:hover',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text:hover',
|
||||
]
|
||||
),
|
||||
'focus_background_color' => implode(
|
||||
',',
|
||||
[
|
||||
'.woocommerce %%order_class%% .select2-container--open .select2-selection',
|
||||
'.woocommerce %%order_class%% form .input-text:focus',
|
||||
]
|
||||
),
|
||||
'focus_background_color_hover' => implode(
|
||||
',',
|
||||
[
|
||||
'.woocommerce %%order_class%% .select2-container--open:hover .select2-selection',
|
||||
'.woocommerce %%order_class%% form .input-text:focus:hover',
|
||||
]
|
||||
),
|
||||
'focus_text_color' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--open .select2-selection__rendered',
|
||||
'.woocommerce %%order_class%% form .form-row input.input-text:focus',
|
||||
)
|
||||
),
|
||||
'focus_text_color_hover' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--open:hover .select2-selection__rendered',
|
||||
'.woocommerce %%order_class%% form .form-row input.input-text:focus:hover',
|
||||
)
|
||||
),
|
||||
'form_text_color' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--default .select2-selection--single .select2-selection__rendered',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text',
|
||||
)
|
||||
),
|
||||
'form_text_color_hover' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container .select2-selection--single:hover .select2-selection__rendered',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text:hover',
|
||||
)
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% .select2-container--default .select2-selection--single',
|
||||
'%%order_class%% form .form-row input.input-text',
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
'border_styles' => array(
|
||||
'form_field' => array(
|
||||
'label_prefix' => esc_html__( 'Fields', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--default .select2-selection--single',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text',
|
||||
)
|
||||
),
|
||||
'border_radii' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--default .select2-selection--single',
|
||||
'.woocommerce %%order_class%% form .form-row input.input-text',
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'solid',
|
||||
),
|
||||
),
|
||||
),
|
||||
'form_field_focus' => array(
|
||||
'label_prefix' => esc_html__( 'Fields Focus', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--default.select2-container--open .select2-selection--single',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text:focus',
|
||||
)
|
||||
),
|
||||
'border_radii' => implode(
|
||||
',',
|
||||
array(
|
||||
'.woocommerce %%order_class%% .select2-container--default.select2-container--open .select2-selection--single',
|
||||
'.woocommerce %%order_class%% form .form-row input.input-text:focus',
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'solid',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'font_field' => array(
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
[
|
||||
'.woocommerce %%order_class%% .select2-container--default .select2-selection--single',
|
||||
'.woocommerce %%order_class%% form .form-row .input-text',
|
||||
]
|
||||
),
|
||||
|
||||
// Required to override default WooCommerce styles.
|
||||
'important' => array( 'line-height', 'size', 'font' ),
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.7em',
|
||||
),
|
||||
),
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% form .form-row input.input-text, %%order_class%% .select2-container--default .select2-selection--single .select2-selection__rendered',
|
||||
'padding' => '%%order_class%% form .form-row input.input-text, %%order_class%% .select2-container--default .select2-selection--single',
|
||||
'margin' => '%%order_class%% form .form-row input.input-text, %%order_class%% .select2-container--default .select2-selection--single',
|
||||
),
|
||||
),
|
||||
'width' => array(),
|
||||
'toggle_priority' => 65,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->custom_css_fields = array(
|
||||
'title_text' => array(
|
||||
'label' => esc_html__( 'Title Text', 'et_builder' ),
|
||||
'selector' => '%%order_class%% h3',
|
||||
),
|
||||
'field_label' => array(
|
||||
'label' => esc_html__( 'Field Label', 'et_builder' ),
|
||||
'selector' => '%%order_class%% form .form-row label',
|
||||
),
|
||||
'form_field' => array(
|
||||
'label' => esc_html__( 'Fields', 'et_builder' ),
|
||||
'selector' => implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% .select2-container--default .select2-selection--single',
|
||||
'%%order_class%% form .form-row .input-text',
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->help_videos = array(
|
||||
array(
|
||||
'id' => esc_html( '7X03vBPYJ1o' ),
|
||||
'name' => esc_html__( 'Divi WooCommerce Modules', 'et_builder' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_fields() {
|
||||
$fields = array(
|
||||
'required_field_indicator_color' => array(
|
||||
'label' => esc_html__( 'Required Field Indicator Color', 'et_builder' ),
|
||||
'description' => esc_html__( 'Pick a color to be used for the required field indicator.', 'et_builder' ),
|
||||
'type' => 'color-alpha',
|
||||
'option_category' => 'button',
|
||||
'custom_color' => true,
|
||||
'default' => '',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'field_label',
|
||||
'hover' => 'tabs',
|
||||
'mobile_options' => true,
|
||||
'priority' => 5,
|
||||
),
|
||||
'fields_width' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'fields_width'
|
||||
),
|
||||
'__checkout_shipping' => array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Shipping',
|
||||
'get_checkout_shipping',
|
||||
),
|
||||
'computed_depends_on' => array(
|
||||
|
||||
/*
|
||||
* `depends_on` arg is required. Otherwise AJAX will return null.
|
||||
* @see et_pb_process_computed_property().
|
||||
* `product` will not be processed since there is no definition in
|
||||
* @see ET_Builder_Module_Woocommerce_Checkout_Order::get_fields()
|
||||
*/
|
||||
'product',
|
||||
),
|
||||
),
|
||||
'placeholder_color' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'placeholder_color'
|
||||
),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_transition_fields_css_props() {
|
||||
$fields = parent::get_transition_fields_css_props();
|
||||
|
||||
$fields['required_field_indicator_color'] = array(
|
||||
'color' => '%%order_class%% form .form-row .required',
|
||||
);
|
||||
$fields['placeholder_color'] = array(
|
||||
'color' => array(
|
||||
'%%order_class%% form .input-text::placeholder',
|
||||
'%%order_class%% form .input-text::-webkit-input-placeholder',
|
||||
'%%order_class%% form .input-text::-moz-placeholder',
|
||||
'%%order_class%% form .input-text:-ms-input-placeholder',
|
||||
),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps Checkout Order Details template.
|
||||
*
|
||||
* Coupon Remove Link must be shown in VB. Hence we swap the template.
|
||||
*
|
||||
* @param string $template Template.
|
||||
* @param string $template_name Template name.
|
||||
* @param array $args Arguments.
|
||||
* @param string $template_path Template path.
|
||||
* @param string $default_path Default path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function swap_template( $template, $template_name, $args, $template_path, $default_path ) {
|
||||
$is_template_override = in_array(
|
||||
$template_name,
|
||||
array(
|
||||
'checkout/form-checkout.php',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
if ( $is_template_override ) {
|
||||
return trailingslashit( ET_BUILDER_DIR ) . 'feature/woocommerce/templates/' . $template_name;
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle hooks.
|
||||
*/
|
||||
public static function maybe_handle_hooks( $conditional_tags ) {
|
||||
$is_tb = et_()->array_get( $conditional_tags, 'is_tb', false );
|
||||
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_coupon_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_login_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_order_review();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::detach_wc_checkout_payment();
|
||||
|
||||
if ( ! et_fb_is_computed_callback_ajax() && ! $is_tb ) {
|
||||
add_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Shipping',
|
||||
'swap_template',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
}
|
||||
|
||||
remove_action(
|
||||
'woocommerce_checkout_billing',
|
||||
[
|
||||
WC_Checkout::instance(),
|
||||
'checkout_form_billing',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset hooks.
|
||||
*/
|
||||
public static function maybe_reset_hooks( $conditional_tags ) {
|
||||
$is_tb = et_()->array_get( $conditional_tags, 'is_tb', false );
|
||||
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_coupon_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_login_form();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_order_review();
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::attach_wc_checkout_payment();
|
||||
|
||||
if ( ! et_fb_is_computed_callback_ajax() && ! $is_tb ) {
|
||||
remove_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Checkout_Shipping',
|
||||
'swap_template',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
}
|
||||
|
||||
add_action(
|
||||
'woocommerce_checkout_billing',
|
||||
[
|
||||
WC_Checkout::instance(),
|
||||
'checkout_form_billing',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Checkout Shipping markup.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_checkout_shipping( $args = array(), $conditional_tags = array() ) {
|
||||
self::maybe_handle_hooks( $conditional_tags );
|
||||
|
||||
$is_cart_empty = function_exists( 'WC' ) && isset( WC()->cart ) && WC()->cart->is_empty();
|
||||
$is_pb_mode = et_fb_is_computed_callback_ajax() || is_et_pb_preview();
|
||||
$class = 'ET_Builder_Module_Helper_Woocommerce_Modules';
|
||||
|
||||
// Set dummy cart contents to output Billing when no product is in cart.
|
||||
if ( ( $is_cart_empty && $is_pb_mode ) || is_et_pb_preview() ) {
|
||||
add_filter(
|
||||
'woocommerce_get_cart_contents',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
array( $class, 'set_dummy_cart_contents' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $is_pb_mode ) {
|
||||
add_filter( 'woocommerce_cart_needs_shipping_address', '__return_true' );
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
WC_Shortcode_Checkout::output( array() );
|
||||
|
||||
$markup = ob_get_clean();
|
||||
|
||||
if ( $is_pb_mode ) {
|
||||
remove_filter( 'woocommerce_cart_needs_shipping_address', '__return_true' );
|
||||
}
|
||||
|
||||
if ( ( $is_cart_empty && $is_pb_mode ) || is_et_pb_preview() ) {
|
||||
remove_filter(
|
||||
'woocommerce_get_cart_contents',
|
||||
array(
|
||||
$class,
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'set_dummy_cart_contents'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
self::maybe_reset_hooks( $conditional_tags );
|
||||
|
||||
// Fallback.
|
||||
if ( ! is_string( $markup ) ) {
|
||||
$markup = '';
|
||||
}
|
||||
|
||||
return $markup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the module output.
|
||||
*
|
||||
* @param array $attrs List of attributes.
|
||||
* @param string $content Content being processed.
|
||||
* @param string $render_slug Slug of module that is used for rendering output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render( $attrs, $content, $render_slug ) {
|
||||
if ( function_exists( 'is_order_received_page' )
|
||||
&& is_order_received_page() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// The module will styled to remain hidden when the class is added.
|
||||
if ( function_exists( 'wc_ship_to_billing_address_only' ) && wc_ship_to_billing_address_only() ) {
|
||||
$this->add_classname( 'et_pb_wc_ship_to_billing_address_only' );
|
||||
}
|
||||
|
||||
$output = self::get_checkout_shipping();
|
||||
|
||||
$fields_width = et_()->array_get( $this->props, 'fields_width', false );
|
||||
if ( false !== $fields_width ) {
|
||||
$this->add_classname( "et_pb_fields_layout_{$fields_width}" );
|
||||
}
|
||||
|
||||
// Handle Required Field Indicator Color responsive and hover fields.
|
||||
$required_field_indicator_color_values = et_pb_responsive_options()->get_property_values( $this->props, 'required_field_indicator_color' );
|
||||
$required_field_indicator_color_hover = $this->get_hover_value( 'required_field_indicator_color' );
|
||||
$required_field_indicator_selector = '%%order_class%% form .form-row .required';
|
||||
|
||||
et_pb_responsive_options()->generate_responsive_css(
|
||||
$required_field_indicator_color_values,
|
||||
$required_field_indicator_selector,
|
||||
'color',
|
||||
$render_slug,
|
||||
' !important;',
|
||||
'color'
|
||||
);
|
||||
|
||||
// Placeholder Color.
|
||||
$placeholder_selectors = array(
|
||||
'%%order_class%% form .form-row input.input-text::placeholder',
|
||||
'%%order_class%% form .form-row input.input-text::-webkit-input-placeholder',
|
||||
'%%order_class%% form .form-row input.input-text::-moz-placeholder',
|
||||
'%%order_class%% form .form-row input.input-text:-ms-input-placeholder',
|
||||
);
|
||||
|
||||
$this->generate_styles(
|
||||
array(
|
||||
'base_attr_name' => 'placeholder_color',
|
||||
'selector' => join( ', ', $placeholder_selectors ),
|
||||
'hover_pseudo_selector_location' => 'suffix',
|
||||
'sticky_pseudo_selector_location' => 'prefix',
|
||||
'css_property' => 'color',
|
||||
'important' => false,
|
||||
'render_slug' => $render_slug,
|
||||
'type' => 'color',
|
||||
)
|
||||
);
|
||||
|
||||
if ( et_builder_is_hover_enabled( 'required_field_indicator_color', $this->props ) ) {
|
||||
ET_Builder_Element::set_style(
|
||||
$render_slug,
|
||||
array(
|
||||
'selector' => '%%order_class%% form .form-row:hover .required',
|
||||
'declaration' => sprintf(
|
||||
'color: %1$s;',
|
||||
esc_html( $required_field_indicator_color_hover )
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->add_classname( $this->get_text_orientation_classname() );
|
||||
|
||||
if ( isset( WC()->cart )
|
||||
&& ! is_null( WC()->cart && method_exists( WC()->cart, 'check_cart_items' ) )
|
||||
&& ! is_et_pb_preview() ) {
|
||||
$return = WC()->cart->check_cart_items();
|
||||
|
||||
if ( wc_notice_count( 'error' ) > 0 ) {
|
||||
$this->add_classname( 'et_pb_hide_module' );
|
||||
}
|
||||
}
|
||||
|
||||
global $wp;
|
||||
if ( ! empty( $wp->query_vars['order-pay'] ) ) {
|
||||
$this->add_classname( 'et_pb_wc_order_pay' );
|
||||
}
|
||||
|
||||
return $this->_render_module_wrapper( $output, $render_slug );
|
||||
}
|
||||
}
|
||||
|
||||
new ET_Builder_Module_Woocommerce_Checkout_Shipping();
|
282
includes/builder/module/woocommerce/CrossSells.php
Normal file
282
includes/builder/module/woocommerce/CrossSells.php
Normal file
@ -0,0 +1,282 @@
|
||||
<?php
|
||||
/**
|
||||
* WooCommerce Modules: ET_Builder_Module_Woocommerce_Cross_Sells class
|
||||
*
|
||||
* The ET_Builder_Module_Woocommerce_Cross_Sells Class is responsible for rendering the
|
||||
* Cross sells using the WooCommerce template.
|
||||
*
|
||||
* @since 4.14.0
|
||||
* @package Divi\Builder
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Cart Upsells component.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
class ET_Builder_Module_Woocommerce_Cross_Sells extends ET_Builder_Module {
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Cross Sells', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Cross Sells', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_cross_sells';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->main_css_element = '%%order_class%%.et_pb_wc_cross_sells';
|
||||
|
||||
$this->advanced_fields = array(
|
||||
'fonts' => array(
|
||||
'title' => array(
|
||||
'label' => et_builder_i18n( 'Title' ),
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
[
|
||||
"{$this->main_css_element} ul.products li.product h3",
|
||||
"{$this->main_css_element} ul.products li.product h1",
|
||||
"{$this->main_css_element} ul.products li.product h2",
|
||||
"{$this->main_css_element} ul.products li.product h4",
|
||||
"{$this->main_css_element} ul.products li.product h5",
|
||||
"{$this->main_css_element} ul.products li.product h6",
|
||||
]
|
||||
),
|
||||
'hover' => implode(
|
||||
',',
|
||||
[
|
||||
"{$this->main_css_element} .woocommerce ul.products li.product h3:hover",
|
||||
"{$this->main_css_element} .woocommerce ul.products li.product h1:hover",
|
||||
"{$this->main_css_element} .woocommerce ul.products li.product h2:hover",
|
||||
"{$this->main_css_element} .woocommerce ul.products li.product h4:hover",
|
||||
"{$this->main_css_element} .woocommerce ul.products li.product h5:hover",
|
||||
"{$this->main_css_element} .woocommerce ul.products li.product h6:hover",
|
||||
]
|
||||
),
|
||||
'important' => 'plugin_only',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1em',
|
||||
),
|
||||
),
|
||||
'price' => array(
|
||||
'label' => esc_html__( 'Price', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
[
|
||||
"{$this->main_css_element} ul.products li.product .price",
|
||||
"{$this->main_css_element} ul.products li.product .price .amount",
|
||||
]
|
||||
),
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'range_settings' => array(
|
||||
'min' => '1',
|
||||
'max' => '100',
|
||||
'step' => '1',
|
||||
),
|
||||
'default' => '26px',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->help_videos = array(
|
||||
array(
|
||||
'id' => esc_html( '7X03vBPYJ1o' ),
|
||||
'name' => esc_html__( 'Divi WooCommerce Modules', 'et_builder' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_fields() {
|
||||
$fields = array(
|
||||
'__cross_sells' => array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
'ET_Builder_Module_Woocommerce_Cross_Sells',
|
||||
'get_cross_sells',
|
||||
),
|
||||
'computed_depends_on' => array(
|
||||
|
||||
/*
|
||||
* `depends_on` arg is required. Otherwise AJAX will return null.
|
||||
* @see et_pb_process_computed_property().
|
||||
* `product` will not be processed since there is no definition in
|
||||
* @see ET_Builder_Module_Woocommerce_Checkout_Order::get_fields()
|
||||
*/
|
||||
'product',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps Cross-sells template.
|
||||
*
|
||||
* @param string $template Template.
|
||||
* @param string $template_name Template name.
|
||||
* @param array $args Arguments.
|
||||
* @param string $template_path Template path.
|
||||
* @param string $default_path Default path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function swap_template( $template, $template_name, $args, $template_path, $default_path ) {
|
||||
$is_template_override = in_array(
|
||||
$template_name,
|
||||
array(
|
||||
'cart/cross-sells.php',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
if ( $is_template_override ) {
|
||||
return trailingslashit( ET_BUILDER_DIR ) . 'feature/woocommerce/templates/' . $template_name;
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Cross sells markup.
|
||||
*
|
||||
* @param array $args Props.
|
||||
* @param array $conditional_tags Conditional tags set during computed property AJAX call.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_cross_sells( $args = array(), $conditional_tags = array() ) {
|
||||
if ( is_checkout() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'woocommerce_cross_sell_display' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$is_tb = et_()->array_get( $conditional_tags, 'is_tb', false );
|
||||
|
||||
$output = '';
|
||||
|
||||
if ( ( $is_tb || et_fb_is_computed_callback_ajax() || is_et_pb_preview() ) ) {
|
||||
$cross_sell_items = array(
|
||||
1001 => array(
|
||||
'name' => esc_html__( 'Product 4', 'et_builder' ),
|
||||
'price' => '12.00',
|
||||
),
|
||||
1002 => array(
|
||||
'name' => esc_html__( 'Product 5', 'et_builder' ),
|
||||
'price' => '75.00',
|
||||
),
|
||||
1003 => array(
|
||||
'name' => esc_html__( 'Product 6', 'et_builder' ),
|
||||
'price' => '38.00',
|
||||
),
|
||||
);
|
||||
|
||||
$cross_sell_products = [];
|
||||
|
||||
foreach ( $cross_sell_items as $id => $details ) {
|
||||
$product = new ET_Builder_Woocommerce_Product_Simple_Placeholder();
|
||||
$product->set_name( $details['name'] );
|
||||
$product->set_id( $id );
|
||||
$product->set_price( $details['price'] );
|
||||
|
||||
$cross_sell_products[] = $product;
|
||||
}
|
||||
|
||||
wc_set_loop_prop( 'name', 'cross-sells' );
|
||||
wc_set_loop_prop( 'columns', apply_filters( 'woocommerce_cross_sells_columns', 2 ) );
|
||||
|
||||
$orderby = apply_filters( 'woocommerce_cross_sells_orderby', 'rand' );
|
||||
$order = apply_filters( 'woocommerce_cross_sells_order', 'desc' );
|
||||
$cross_sells = wc_products_array_orderby( $cross_sell_products, $orderby, $order );
|
||||
$limit = apply_filters( 'woocommerce_cross_sells_total', 0 );
|
||||
$cross_sells = $limit > 0 ? array_slice( $cross_sells, 0, $limit ) : $cross_sells;
|
||||
|
||||
// Runs only on Builder mode.
|
||||
add_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Cross_Sells',
|
||||
'swap_template',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
|
||||
ob_start();
|
||||
wc_get_template(
|
||||
'cart/cross-sells.php',
|
||||
array(
|
||||
'cross_sells' => $cross_sells,
|
||||
|
||||
// Not used now, but used in previous version of up-sells.php.
|
||||
'posts_per_page' => $limit,
|
||||
'orderby' => $orderby,
|
||||
'columns' => 2,
|
||||
)
|
||||
);
|
||||
$output = ob_get_clean();
|
||||
|
||||
remove_filter(
|
||||
'wc_get_template',
|
||||
[
|
||||
'ET_Builder_Module_Woocommerce_Cross_Sells',
|
||||
'swap_template',
|
||||
],
|
||||
10,
|
||||
5
|
||||
);
|
||||
} else {
|
||||
if ( ! is_null( WC()->cart ) ) {
|
||||
ob_start();
|
||||
woocommerce_cross_sell_display( 0 );
|
||||
$output = ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the module output.
|
||||
*
|
||||
* @param array $attrs List of attributes.
|
||||
* @param string $content Content being processed.
|
||||
* @param string $render_slug Slug of module that is used for rendering output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render( $attrs, $content, $render_slug ) {
|
||||
// Module classnames.
|
||||
$this->add_classname(
|
||||
array(
|
||||
$this->get_text_orientation_classname(),
|
||||
)
|
||||
);
|
||||
|
||||
$output = self::get_cross_sells();
|
||||
|
||||
return $this->_render_module_wrapper( $output, $render_slug );
|
||||
}
|
||||
}
|
||||
|
||||
new ET_Builder_Module_Woocommerce_Cross_Sells();
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Description component.
|
||||
*/
|
||||
@ -20,10 +22,11 @@ class ET_Builder_Module_Woocommerce_Description extends ET_Builder_Module {
|
||||
* @since 4.0.6 Updated `toggle_slug` to avoid empty Tabs in Text OG.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Description', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Descriptions', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_description';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Description', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Description', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_description';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
@ -382,7 +385,7 @@ class ET_Builder_Module_Woocommerce_Description extends ET_Builder_Module {
|
||||
|
||||
// Theme builder's description placeholder; short-circuit is cleaner and more efficient than
|
||||
// global object element being modified. NOTE: $conditional_tags element value is string
|
||||
if ( et_builder_tb_enabled() || 'true' === et_()->array_get( $conditional_tags, 'is_tb', false ) ) {
|
||||
if ( et_builder_tb_enabled() || 'true' === et_()->array_get( $conditional_tags, 'is_tb', false ) || is_et_pb_preview() ) {
|
||||
$placeholders = et_theme_builder_wc_placeholders();
|
||||
|
||||
$description = 'short_description' === $args['description_type'] ?
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'ET_Builder_Module_Gallery' ) ) {
|
||||
require_once ET_BUILDER_DIR_RESOLVED_PATH . '/module/Gallery.php';
|
||||
}
|
||||
@ -26,9 +28,10 @@ class ET_Builder_Module_Woocommerce_Gallery extends ET_Builder_Module_Gallery {
|
||||
public function init() {
|
||||
parent::init();
|
||||
|
||||
$this->name = esc_html__( 'Woo Gallery', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Galleries', 'et_builder' );
|
||||
$this->name = esc_html__( 'Woo Product Gallery', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Gallery', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_gallery';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
$this->main_css_element = '%%order_class%%';
|
||||
|
||||
// Intentionally removing inherited options group.
|
||||
@ -222,7 +225,7 @@ class ET_Builder_Module_Woocommerce_Gallery extends ET_Builder_Module_Gallery {
|
||||
* @return array
|
||||
*/
|
||||
public static function get_wc_gallery( $args = array(), $conditional_tags = array(), $current_page = array() ) {
|
||||
if ( 'current' === $args['product'] && 'true' === et_()->array_get( $conditional_tags, 'is_tb', false ) ) {
|
||||
if ( 'current' === $args['product'] && 'true' === et_()->array_get( $conditional_tags, 'is_tb', false ) || is_et_pb_preview() ) {
|
||||
et_theme_builder_wc_set_global_objects( $conditional_tags );
|
||||
|
||||
global $product;
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Images component.
|
||||
*/
|
||||
@ -18,9 +20,11 @@ class ET_Builder_Module_Woocommerce_Images extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Images', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_images';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Images', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Images', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_images';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
@ -32,14 +36,15 @@ class ET_Builder_Module_Woocommerce_Images extends ET_Builder_Module {
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'image' => et_builder_i18n( 'Image' ),
|
||||
'sale_badge' => esc_html__( 'Sale Badge Text', 'et_builder' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->advanced_fields = array(
|
||||
'borders' => array(
|
||||
'default' => array(),
|
||||
'image' => array(
|
||||
'default' => array(),
|
||||
'image' => array(
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_radii' => '%%order_class%% div.images ol.flex-control-thumbs.flex-control-nav li, %%order_class%% .flex-viewport, %%order_class%% .woocommerce-product-gallery--without-images .woocommerce-product-gallery__wrapper, %%order_class%% .woocommerce-product-gallery > div:not(.flex-viewport) .woocommerce-product-gallery__image, %%order_class%% .woocommerce-product-gallery > .woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image, %%order_class%% .woocommerce-product-gallery .woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image',
|
||||
@ -50,10 +55,25 @@ class ET_Builder_Module_Woocommerce_Images extends ET_Builder_Module {
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'image',
|
||||
),
|
||||
'sale_badge' => array(
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_radii' => '%%order_class%% span.onsale',
|
||||
'border_styles' => '%%order_class%% span.onsale',
|
||||
),
|
||||
'important' => true,
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|3px|3px|3px|3px',
|
||||
),
|
||||
'label_prefix' => esc_html__( 'Sale Badge', 'et_builder' ),
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'sale_badge',
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'default' => array(),
|
||||
'image' => array(
|
||||
'default' => array(),
|
||||
'image' => array(
|
||||
'label' => esc_html__( 'Image Box Shadow', 'et_builder' ),
|
||||
'option_category' => 'layout',
|
||||
'tab_slug' => 'advanced',
|
||||
@ -64,6 +84,17 @@ class ET_Builder_Module_Woocommerce_Images extends ET_Builder_Module {
|
||||
'important' => true,
|
||||
),
|
||||
),
|
||||
'sale_badge' => array(
|
||||
'label' => esc_html__( 'Sale Badge Box Shadow', 'et_builder' ),
|
||||
'option_category' => 'layout',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'sale_badge',
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% span.onsale',
|
||||
'overlay' => 'inset',
|
||||
'important' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
'background' => array(),
|
||||
'margin_padding' => array(
|
||||
@ -93,6 +124,31 @@ class ET_Builder_Module_Woocommerce_Images extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
'button' => false,
|
||||
'form_field' => array(
|
||||
'sale_badge' => array(
|
||||
'label' => esc_html__( 'Sale Badge', 'et_builder' ),
|
||||
'background_color' => false,
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% ul.products li.product span.onsale',
|
||||
'important' => array( 'custom_margin', 'custom_padding' ),
|
||||
),
|
||||
'custom_margin' => array(
|
||||
'default' => '0px|0px|0px|0px|false|false',
|
||||
),
|
||||
'custom_padding' => array(
|
||||
'default' => '6px|18px|6px|18px|false|false',
|
||||
),
|
||||
'toggle_slug' => 'sale_badge',
|
||||
),
|
||||
'border_styles' => false,
|
||||
'box_shadow' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->help_videos = array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Meta component.
|
||||
*/
|
||||
@ -18,10 +20,11 @@ class ET_Builder_Module_Woocommerce_Meta extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Meta', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Metas', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_meta';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Meta', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Meta', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_meta';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Price component.
|
||||
*/
|
||||
@ -18,12 +20,13 @@ class ET_Builder_Module_Woocommerce_Price extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Price', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Prices', 'et_builder' );
|
||||
$this->name = esc_html__( 'Woo Product Price', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Price', 'et_builder' );
|
||||
|
||||
// Use `et_pb_wc_{module}` for all WooCommerce modules.
|
||||
$this->slug = 'et_pb_wc_price';
|
||||
$this->vb_support = 'on';
|
||||
$this->slug = 'et_pb_wc_price';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Rating component.
|
||||
*/
|
||||
@ -20,10 +22,11 @@ class ET_Builder_Module_Woocommerce_Rating extends ET_Builder_Module {
|
||||
* @since 3.29.2 Added custom margin default.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Rating', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Ratings', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_rating';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Rating', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Rating', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_rating';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Related Products component.
|
||||
*
|
||||
@ -26,6 +28,13 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
*/
|
||||
public static $static_props;
|
||||
|
||||
/**
|
||||
* Number of products to be offset.
|
||||
*
|
||||
* @var int Default 0.
|
||||
*/
|
||||
public static $offset = 0;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
@ -33,12 +42,13 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
* @see {https://github.com/elegantthemes/Divi/issues/17436}
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Related Product', 'et_builder' );
|
||||
$this->name = esc_html__( 'Woo Related Products', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Related Products', 'et_builder' );
|
||||
|
||||
// Use `et_pb_wc_{module}` for all WooCommerce modules.
|
||||
$this->slug = 'et_pb_wc_related_products';
|
||||
$this->vb_support = 'on';
|
||||
$this->slug = 'et_pb_wc_related_products';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->main_css_element = '%%order_class%%';
|
||||
|
||||
@ -46,14 +56,16 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
'general' => array(
|
||||
'toggles' => array(
|
||||
'main_content' => et_builder_i18n( 'Content' ),
|
||||
'elements' => et_builder_i18n( 'Elements' ),
|
||||
),
|
||||
),
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'overlay' => et_builder_i18n( 'Overlay' ),
|
||||
'image' => et_builder_i18n( 'Image' ),
|
||||
'overlay' => et_builder_i18n( 'Overlay' ),
|
||||
'image' => et_builder_i18n( 'Image' ),
|
||||
// Avoid Text suffix by manually defining the `star` toggle slug.
|
||||
'star' => esc_html__( 'Star Rating', 'et_builder' ),
|
||||
'star' => esc_html__( 'Star Rating', 'et_builder' ),
|
||||
'sale_badge' => esc_html__( 'Sale Badge Text', 'et_builder' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -168,7 +180,7 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
'borders' => array(
|
||||
'default' => array(
|
||||
'default' => array(
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_radii' => '%%order_class%%.et_pb_wc_related_products .product',
|
||||
@ -176,7 +188,7 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
),
|
||||
'image' => array(
|
||||
'image' => array(
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_radii' => '%%order_class%%.et_pb_module .et_shop_image',
|
||||
@ -188,14 +200,29 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'image',
|
||||
),
|
||||
'sale_badge' => array(
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_radii' => '%%order_class%% span.onsale',
|
||||
'border_styles' => '%%order_class%% span.onsale',
|
||||
),
|
||||
'important' => true,
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|3px|3px|3px|3px',
|
||||
),
|
||||
'label_prefix' => esc_html__( 'Sale Badge', 'et_builder' ),
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'sale_badge',
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'default' => array(
|
||||
'default' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% .product',
|
||||
),
|
||||
),
|
||||
'image' => array(
|
||||
'image' => array(
|
||||
'label' => esc_html__( 'Image Box Shadow', 'et_builder' ),
|
||||
'option_category' => 'layout',
|
||||
'tab_slug' => 'advanced',
|
||||
@ -209,6 +236,17 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
'position' => '',
|
||||
),
|
||||
),
|
||||
'sale_badge' => array(
|
||||
'label' => esc_html__( 'Sale Badge Box Shadow', 'et_builder' ),
|
||||
'option_category' => 'layout',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'sale_badge',
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% span.onsale',
|
||||
'overlay' => 'inset',
|
||||
'important' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
@ -250,6 +288,31 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
'button' => false,
|
||||
'form_field' => array(
|
||||
'sale_badge' => array(
|
||||
'label' => esc_html__( 'Sale Badge', 'et_builder' ),
|
||||
'background_color' => false,
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% ul.products li.product span.onsale',
|
||||
'important' => array( 'custom_margin', 'custom_padding' ),
|
||||
),
|
||||
'custom_margin' => array(
|
||||
'default' => '0px|0px|0px|0px|false|false',
|
||||
),
|
||||
'custom_padding' => array(
|
||||
'default' => '6px|18px|6px|18px|false|false',
|
||||
),
|
||||
'toggle_slug' => 'sale_badge',
|
||||
),
|
||||
'border_styles' => false,
|
||||
'box_shadow' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->custom_css_fields = array(
|
||||
@ -352,6 +415,24 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
),
|
||||
)
|
||||
),
|
||||
'include_categories' => array(
|
||||
'label' => esc_html__( 'Included Categories', 'et_builder' ),
|
||||
'type' => 'categories',
|
||||
'meta_categories' => array(
|
||||
'all' => esc_html__( 'All Categories', 'et_builder' ),
|
||||
'current' => esc_html__( 'Current Category', 'et_builder' ),
|
||||
),
|
||||
'renderer_options' => array(
|
||||
'use_terms' => true,
|
||||
'term_name' => 'product_cat',
|
||||
),
|
||||
'description' => esc_html__( 'Choose which categories you would like to include.', 'et_builder' ),
|
||||
'taxonomy_name' => 'product_cat',
|
||||
'toggle_slug' => 'main_content',
|
||||
'computed_affects' => array(
|
||||
'__related_products',
|
||||
),
|
||||
),
|
||||
'sale_badge_color' => array(
|
||||
'label' => esc_html__( 'Sale Badge Color', 'et_builder' ),
|
||||
'description' => esc_html__( 'Pick a color to use for the sales bade that appears on products that are on sale.', 'et_builder' ),
|
||||
@ -394,6 +475,84 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
'mobile_options' => true,
|
||||
'sticky' => true,
|
||||
),
|
||||
'show_name' => array(
|
||||
'label' => esc_html__( 'Show Name', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn name on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_image' => array(
|
||||
'label' => esc_html__( 'Show Image', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn image on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_price' => array(
|
||||
'label' => esc_html__( 'Show Price', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn price on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_rating' => array(
|
||||
'label' => esc_html__( 'Show Rating', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn rating on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_sale_badge' => array(
|
||||
'label' => esc_html__( 'Show Sale Badge', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn sale badge on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'offset_number' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'offset_number',
|
||||
array(
|
||||
'computed_affects' => array(
|
||||
'__related_products',
|
||||
),
|
||||
)
|
||||
),
|
||||
'__related_products' => array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
@ -406,6 +565,8 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
'posts_number',
|
||||
'columns_number',
|
||||
'orderby',
|
||||
'offset_number',
|
||||
'include_categories',
|
||||
),
|
||||
'computed_minimum' => array(
|
||||
'product',
|
||||
@ -416,6 +577,50 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the related product category Ids.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*
|
||||
* @param array $term_ids Term IDs.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function set_related_products_categories( $term_ids ) {
|
||||
$include_cats = et_()->array_get( self::$static_props, 'include_categories', '' );
|
||||
$meta_cats = array( 'all', 'current' );
|
||||
|
||||
// WooCommerce by default handles All & Current based on the global $product.
|
||||
// So return the filtered $term_ids to let WooCommerce take control.
|
||||
if ( in_array( $include_cats, $meta_cats, true ) || empty( $include_cats ) ) {
|
||||
return $term_ids;
|
||||
}
|
||||
|
||||
// Return user selected categories if they exist.
|
||||
$include_cats = explode( ',', $include_cats );
|
||||
|
||||
return $include_cats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends offset to the WP_Query that retrieves Products.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*
|
||||
* @param array $query_args Query args.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function append_offset( $query_args ) {
|
||||
if ( ! is_array( $query_args ) ) {
|
||||
return $query_args;
|
||||
}
|
||||
|
||||
$query_args['offset'] = self::$offset;
|
||||
|
||||
return $query_args;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -450,31 +655,105 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
* we pass them via a static variable.
|
||||
*/
|
||||
self::$static_props = $args;
|
||||
$offset_number = et_()->array_get( $args, 'offset_number', 0 );
|
||||
$include_cats = et_()->array_get( $args, 'include_categories', '' );
|
||||
$show_price = et_()->array_get( $args, 'show_price', 'on' );
|
||||
$include_cats = ! empty( $include_cats ) ? explode( ',', $include_cats ) : array();
|
||||
$is_include_cats = is_array( $include_cats ) && count( $include_cats ) > 0;
|
||||
|
||||
// Force set product's class to ET_Theme_Builder_Woocommerce_Product_Variable_Placeholder
|
||||
// in TB so related product can outputs visible content based on pre-filled value in TB
|
||||
if ( 'true' === et_()->array_get( $conditional_tags, 'is_tb', false ) ) {
|
||||
if ( 'true' === et_()->array_get( $conditional_tags, 'is_tb', false ) || is_et_pb_preview() ) {
|
||||
add_filter( 'woocommerce_product_class', 'et_theme_builder_wc_product_class' );
|
||||
}
|
||||
|
||||
$is_offset_valid = absint( $offset_number ) > 0;
|
||||
if ( $is_offset_valid ) {
|
||||
self::$offset = $offset_number;
|
||||
|
||||
add_filter(
|
||||
'woocommerce_shortcode_products_query',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Related_Products',
|
||||
'append_offset',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( $is_include_cats ) {
|
||||
$product_id = et_builder_wc_get_product_id( $args );
|
||||
// To include only selected categories the cached transient should be flushed,
|
||||
// so WooCommerce can compute the categories and cache it again.
|
||||
delete_transient( 'wc_related_' . $product_id );
|
||||
|
||||
add_filter(
|
||||
'woocommerce_get_related_product_cat_terms',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Related_Products',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'set_related_products_categories'
|
||||
)
|
||||
);
|
||||
|
||||
// Also disable related Products by tag
|
||||
// so Products from other categories are not included.
|
||||
add_filter( 'woocommerce_product_related_posts_relate_by_tag', '__return_false' );
|
||||
}
|
||||
|
||||
add_filter(
|
||||
'woocommerce_output_related_products_args',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Related_Products',
|
||||
'set_related_products_args',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'set_related_products_args'
|
||||
)
|
||||
);
|
||||
|
||||
if ( 'off' === $show_price ) {
|
||||
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price' );
|
||||
}
|
||||
|
||||
$output = et_builder_wc_render_module_template( 'woocommerce_output_related_products', $args );
|
||||
|
||||
remove_filter(
|
||||
'woocommerce_output_related_products_args',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Related_Products',
|
||||
'set_related_products_args',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'set_related_products_args'
|
||||
)
|
||||
);
|
||||
|
||||
if ( $is_include_cats ) {
|
||||
remove_filter(
|
||||
'woocommerce_get_related_product_cat_terms',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Related_Products',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'set_related_products_categories'
|
||||
)
|
||||
);
|
||||
|
||||
remove_filter( 'woocommerce_product_related_posts_relate_by_tag', '__return_false' );
|
||||
}
|
||||
|
||||
if ( $is_offset_valid ) {
|
||||
remove_filter(
|
||||
'woocommerce_shortcode_products_query',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Related_Products',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'append_offset'
|
||||
)
|
||||
);
|
||||
|
||||
self::$offset = 0;
|
||||
}
|
||||
|
||||
if ( 'off' === $show_price ) {
|
||||
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price' );
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
@ -553,6 +832,54 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
return $selected_args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Multi view attributes to the Outer wrapper.
|
||||
*
|
||||
* Since we do not have control over the WooCommerce Related Products markup, we inject Multi
|
||||
* view attributes on to the Outer wrapper.
|
||||
*
|
||||
* @param array $outer_wrapper_attrs Outer wrapper attributes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_multi_view_attrs( $outer_wrapper_attrs ) {
|
||||
$multi_view = et_pb_multi_view_options( $this );
|
||||
|
||||
// phpcs:disable WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned -- Invalid warning.
|
||||
$multi_view_attrs = $multi_view->render_attrs(
|
||||
array(
|
||||
'classes' => array(
|
||||
'et_pb_wc_related_products_no_name' => array(
|
||||
'show_name' => 'off',
|
||||
),
|
||||
'et_pb_wc_related_products_no_image' => array(
|
||||
'show_image' => 'off',
|
||||
),
|
||||
'et_pb_wc_related_products_no_price' => array(
|
||||
'show_price' => 'off',
|
||||
),
|
||||
'et_pb_wc_related_products_no_rating' => array(
|
||||
'show_rating' => 'off',
|
||||
),
|
||||
'et_pb_wc_related_products_no_sale_badge' => array(
|
||||
'show_sale_badge' => 'off',
|
||||
),
|
||||
|
||||
),
|
||||
),
|
||||
false,
|
||||
null,
|
||||
true
|
||||
);
|
||||
// phpcs:enable WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned
|
||||
|
||||
if ( $multi_view_attrs && is_array( $multi_view_attrs ) ) {
|
||||
$outer_wrapper_attrs = array_merge( $outer_wrapper_attrs, $multi_view_attrs );
|
||||
}
|
||||
|
||||
return $outer_wrapper_attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the module output.
|
||||
*
|
||||
@ -680,19 +1007,30 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
"et_builder_module_{$render_slug}_outer_wrapper_attrs",
|
||||
array(
|
||||
'ET_Builder_Module_Helper_Woocommerce_Modules',
|
||||
'output_data_icon_attrs',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'output_data_icon_attrs'
|
||||
),
|
||||
10,
|
||||
2
|
||||
);
|
||||
|
||||
add_filter(
|
||||
"et_builder_module_{$render_slug}_outer_wrapper_attrs",
|
||||
array(
|
||||
$this,
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'add_multi_view_attrs',
|
||||
)
|
||||
);
|
||||
|
||||
$output = $this->_render_module_wrapper( $output, $render_slug );
|
||||
|
||||
remove_filter(
|
||||
"et_builder_module_{$render_slug}_outer_wrapper_attrs",
|
||||
array(
|
||||
'ET_Builder_Module_Helper_Woocommerce_Modules',
|
||||
'output_data_icon_attrs',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'output_data_icon_attrs'
|
||||
),
|
||||
10
|
||||
);
|
||||
|
@ -13,6 +13,8 @@ if ( ! class_exists( 'ET_Builder_Module_Gallery' ) ) {
|
||||
require_once ET_BUILDER_DIR_RESOLVED_PATH . '/module/Comments.php';
|
||||
}
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Reviews component.
|
||||
*/
|
||||
@ -26,9 +28,10 @@ class ET_Builder_Module_Woocommerce_Reviews extends ET_Builder_Module_Comments {
|
||||
parent::init();
|
||||
|
||||
// Define basic module information.
|
||||
$this->name = esc_html__( 'Woo Reviews', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Reviews', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_reviews';
|
||||
$this->name = esc_html__( 'Woo Product Reviews', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Reviews', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_reviews';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
// Modify toggle settings.
|
||||
$this->settings_modal_toggles['general']['toggles']['main_content'] = array(
|
||||
@ -189,6 +192,20 @@ class ET_Builder_Module_Woocommerce_Reviews extends ET_Builder_Module_Comments {
|
||||
),
|
||||
)
|
||||
);
|
||||
$fields['show_rating'] = array(
|
||||
'label' => esc_html__( 'Show Rating', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn rating on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
);
|
||||
$fields['__reviews'] = array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
@ -263,7 +280,7 @@ class ET_Builder_Module_Woocommerce_Reviews extends ET_Builder_Module_Comments {
|
||||
|
||||
$is_tb = et_builder_tb_enabled();
|
||||
|
||||
if ( $is_tb ) {
|
||||
if ( $is_tb || is_et_pb_preview() ) {
|
||||
global $product;
|
||||
|
||||
et_theme_builder_wc_set_global_objects();
|
||||
@ -277,7 +294,7 @@ class ET_Builder_Module_Woocommerce_Reviews extends ET_Builder_Module_Comments {
|
||||
|
||||
$reviews_markup = self::get_reviews_markup( $product, $args['header_level'], true );
|
||||
|
||||
if ( $is_tb ) {
|
||||
if ( $is_tb || is_et_pb_preview() ) {
|
||||
et_theme_builder_wc_reset_global_objects();
|
||||
}
|
||||
|
||||
|
1297
includes/builder/module/woocommerce/Shop.php
Normal file
1297
includes/builder/module/woocommerce/Shop.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Stock component.
|
||||
*/
|
||||
@ -18,10 +20,11 @@ class ET_Builder_Module_Woocommerce_Stock extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Stock', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Stock', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_stock';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Stock', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Stock', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_stock';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'ET_Builder_Module_Tabs' ) ) {
|
||||
require_once ET_BUILDER_DIR_RESOLVED_PATH . '/module/Tabs.php';
|
||||
}
|
||||
@ -28,9 +30,10 @@ class ET_Builder_Module_Woocommerce_Tabs extends ET_Builder_Module_Tabs {
|
||||
parent::init();
|
||||
|
||||
// Define WooCommerce Tabs module property; overwriting inherited property.
|
||||
$this->name = esc_html__( 'Woo Tabs', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Tabs', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_tabs';
|
||||
$this->name = esc_html__( 'Woo Product Tabs', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Tabs', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_tabs';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
/*
|
||||
* Set property for holding rendering data so the data rendering via
|
||||
@ -336,7 +339,9 @@ class ET_Builder_Module_Woocommerce_Tabs extends ET_Builder_Module_Tabs {
|
||||
// Check if TB is used
|
||||
$is_tb = et_builder_tb_enabled();
|
||||
|
||||
if ( $is_tb ) {
|
||||
$is_use_placeholder = $is_tb || is_et_pb_preview();
|
||||
|
||||
if ( $is_use_placeholder ) {
|
||||
et_theme_builder_wc_set_global_objects();
|
||||
} elseif ( $overwrite_global ) {
|
||||
// Save current global variable for later reset.
|
||||
@ -363,7 +368,7 @@ class ET_Builder_Module_Woocommerce_Tabs extends ET_Builder_Module_Tabs {
|
||||
}
|
||||
|
||||
if ( 'description' === $name ) {
|
||||
if ( ! et_builder_tb_enabled() && ! et_pb_is_pagebuilder_used( $product_id ) ) {
|
||||
if ( ! $is_use_placeholder && ! et_pb_is_pagebuilder_used( $product_id ) ) {
|
||||
// If selected product doesn't use builder, retrieve post content.
|
||||
if ( et_theme_builder_overrides_layout( ET_THEME_BUILDER_BODY_LAYOUT_POST_TYPE ) ) {
|
||||
$tab_content = apply_filters( 'et_builder_wc_description', $post->post_content );
|
||||
@ -376,7 +381,7 @@ class ET_Builder_Module_Woocommerce_Tabs extends ET_Builder_Module_Tabs {
|
||||
* which might cause infinite loop; get Divi's long description from
|
||||
* post meta instead.
|
||||
*/
|
||||
if ( et_builder_tb_enabled() ) {
|
||||
if ( $is_use_placeholder ) {
|
||||
$placeholders = et_theme_builder_wc_placeholders();
|
||||
|
||||
$tab_content = $placeholders['description'];
|
||||
@ -413,7 +418,7 @@ class ET_Builder_Module_Woocommerce_Tabs extends ET_Builder_Module_Tabs {
|
||||
}
|
||||
|
||||
// Reset overwritten global variable.
|
||||
if ( $is_tb ) {
|
||||
if ( $is_use_placeholder ) {
|
||||
et_theme_builder_wc_reset_global_objects();
|
||||
} elseif ( $overwrite_global ) {
|
||||
$product = $original_product;
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Title component.
|
||||
*/
|
||||
@ -18,10 +20,11 @@ class ET_Builder_Module_Woocommerce_Title extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Title', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Titles', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_title';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Title', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Title', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_title';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Upsells component.
|
||||
*/
|
||||
@ -21,16 +23,24 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
*/
|
||||
public static $static_props;
|
||||
|
||||
/**
|
||||
* Number of products to be offset.
|
||||
*
|
||||
* @var int Default 0.
|
||||
*/
|
||||
public static $offset = 0;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Upsell', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Upsells', 'et_builder' );
|
||||
$this->name = esc_html__( 'Woo Product Upsell', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Upsell', 'et_builder' );
|
||||
|
||||
// Use `et_pb_wc_{module}` for all WooCommerce modules.
|
||||
$this->slug = 'et_pb_wc_upsells';
|
||||
$this->vb_support = 'on';
|
||||
$this->slug = 'et_pb_wc_upsells';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->main_css_element = '%%order_class%%';
|
||||
|
||||
@ -38,14 +48,16 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'general' => array(
|
||||
'toggles' => array(
|
||||
'main_content' => et_builder_i18n( 'Content' ),
|
||||
'elements' => et_builder_i18n( 'Elements' ),
|
||||
),
|
||||
),
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'overlay' => et_builder_i18n( 'Overlay' ),
|
||||
'image' => et_builder_i18n( 'Image' ),
|
||||
'overlay' => et_builder_i18n( 'Overlay' ),
|
||||
'image' => et_builder_i18n( 'Image' ),
|
||||
// Avoid Text suffix by manually defining the `star` toggle slug.
|
||||
'star' => esc_html__( 'Star Rating', 'et_builder' ),
|
||||
'star' => esc_html__( 'Star Rating', 'et_builder' ),
|
||||
'sale_badge' => esc_html__( 'Sale Badge Text', 'et_builder' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -73,7 +85,8 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'letter_spacing_hover' => '%%order_class%% ul.products li.product:hover .star-rating',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => 14,
|
||||
'default' => '14px',
|
||||
'label' => esc_html__( 'Star Rating Size', 'et_builder' ),
|
||||
),
|
||||
'hide_font' => true,
|
||||
'hide_line_height' => true,
|
||||
@ -81,9 +94,6 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'text_align' => array(
|
||||
'label' => esc_html__( 'Star Rating Alignment', 'et_builder' ),
|
||||
),
|
||||
'font_size' => array(
|
||||
'label' => esc_html__( 'Star Rating Size', 'et_builder' ),
|
||||
),
|
||||
'text_color' => array(
|
||||
'label' => esc_html__( 'Star Rating Color', 'et_builder' ),
|
||||
),
|
||||
@ -179,14 +189,29 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'image',
|
||||
),
|
||||
'sale_badge' => array(
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_radii' => '%%order_class%% span.onsale',
|
||||
'border_styles' => '%%order_class%% span.onsale',
|
||||
),
|
||||
'important' => true,
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|3px|3px|3px|3px',
|
||||
),
|
||||
'label_prefix' => esc_html__( 'Sale Badge', 'et_builder' ),
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'sale_badge',
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'default' => array(
|
||||
'default' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% .product',
|
||||
),
|
||||
),
|
||||
'image' => array(
|
||||
'image' => array(
|
||||
'label' => esc_html__( 'Image Box Shadow', 'et_builder' ),
|
||||
'option_category' => 'layout',
|
||||
'tab_slug' => 'advanced',
|
||||
@ -200,6 +225,17 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'position' => '',
|
||||
),
|
||||
),
|
||||
'sale_badge' => array(
|
||||
'label' => esc_html__( 'Sale Badge Box Shadow', 'et_builder' ),
|
||||
'option_category' => 'layout',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'sale_badge',
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% span.onsale',
|
||||
'overlay' => 'inset',
|
||||
'important' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
@ -240,6 +276,31 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
'button' => false,
|
||||
'form_field' => array(
|
||||
'sale_badge' => array(
|
||||
'label' => esc_html__( 'Sale Badge', 'et_builder' ),
|
||||
'background_color' => false,
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% ul.products li.product span.onsale',
|
||||
'important' => array( 'custom_margin', 'custom_padding' ),
|
||||
),
|
||||
'custom_margin' => array(
|
||||
'default' => '0px|0px|0px|0px|false|false',
|
||||
),
|
||||
'custom_padding' => array(
|
||||
'default' => '6px|18px|6px|18px|false|false',
|
||||
),
|
||||
'toggle_slug' => 'sale_badge',
|
||||
),
|
||||
'border_styles' => false,
|
||||
'box_shadow' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->custom_css_fields = array(
|
||||
@ -384,6 +445,84 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'mobile_options' => true,
|
||||
'sticky' => true,
|
||||
),
|
||||
'show_name' => array(
|
||||
'label' => esc_html__( 'Show Name', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn name on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_image' => array(
|
||||
'label' => esc_html__( 'Show Image', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn image on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_price' => array(
|
||||
'label' => esc_html__( 'Show Price', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn price on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_rating' => array(
|
||||
'label' => esc_html__( 'Show Rating', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn rating on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_sale_badge' => array(
|
||||
'label' => esc_html__( 'Show Sale Badge', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn sale badge on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'offset_number' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'offset_number',
|
||||
array(
|
||||
'computed_affects' => array(
|
||||
'__upsells',
|
||||
),
|
||||
)
|
||||
),
|
||||
'__upsells' => array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
@ -396,6 +535,7 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'posts_number',
|
||||
'columns_number',
|
||||
'orderby',
|
||||
'offset_number',
|
||||
),
|
||||
'computed_minimum' => array(
|
||||
'product',
|
||||
@ -406,6 +546,25 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends offset to the WP_Query that retrieves Products.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*
|
||||
* @param array $query_args Query args.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function append_offset( $query_args ) {
|
||||
if ( ! is_array( $query_args ) ) {
|
||||
return $query_args;
|
||||
}
|
||||
|
||||
$query_args['offset'] = self::$offset;
|
||||
|
||||
return $query_args;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -433,10 +592,11 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
*/
|
||||
public static function get_upsells( $args = array(), $conditional_tags = array(), $current_page = array() ) {
|
||||
self::$static_props = $args;
|
||||
$offset_number = et_()->array_get( $args, 'offset_number', 0 );
|
||||
|
||||
// Force set product's class to ET_Theme_Builder_Woocommerce_Product_Variable_Placeholder
|
||||
// in TB so related product can outputs visible content based on pre-filled value in TB
|
||||
if ( 'true' === et_()->array_get( $conditional_tags, 'is_tb', false ) ) {
|
||||
if ( 'true' === et_()->array_get( $conditional_tags, 'is_tb', false ) || is_et_pb_preview() ) {
|
||||
// Set upsells id; adjust it with module's arguments. This is specifically needed if
|
||||
// the module fetched the value via computed callback due to some fields no longer uses
|
||||
// default value
|
||||
@ -449,6 +609,16 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
add_filter( 'woocommerce_product_class', 'et_theme_builder_wc_product_class' );
|
||||
}
|
||||
|
||||
$is_offset_valid = absint( $offset_number ) > 0;
|
||||
if ( $is_offset_valid ) {
|
||||
self::$offset = $offset_number;
|
||||
|
||||
add_filter(
|
||||
'woocommerce_shortcode_products_query',
|
||||
array( 'ET_Builder_Module_Woocommerce_Upsells', 'append_offset' )
|
||||
);
|
||||
}
|
||||
|
||||
add_filter(
|
||||
'woocommerce_upsell_display_args',
|
||||
array(
|
||||
@ -474,12 +644,18 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
|
||||
remove_filter(
|
||||
'woocommerce_upsell_display_args',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Upsells',
|
||||
'set_upsell_display_args',
|
||||
)
|
||||
array( 'ET_Builder_Module_Woocommerce_Upsells', 'set_upsell_display_args' )
|
||||
);
|
||||
|
||||
if ( $is_offset_valid ) {
|
||||
remove_filter(
|
||||
'woocommerce_shortcode_products_query',
|
||||
array( 'ET_Builder_Module_Woocommerce_Upsells', 'append_offset' )
|
||||
);
|
||||
|
||||
self::$offset = 0;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
@ -538,6 +714,51 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
return $selected_args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Multi view attributes to the Outer wrapper.
|
||||
*
|
||||
* Since we do not have control over the WooCommerce Related Products markup, we inject Multi
|
||||
* view attributes on to the Outer wrapper.
|
||||
*
|
||||
* @param array $outer_wrapper_attrs Outer wrapper attributes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_multi_view_attrs( $outer_wrapper_attrs ) {
|
||||
$multi_view = et_pb_multi_view_options( $this );
|
||||
|
||||
$multi_view_attrs = $multi_view->render_attrs(
|
||||
array(
|
||||
'classes' => array(
|
||||
'et_pb_wc_upsells_no_name' => array(
|
||||
'show_name' => 'off',
|
||||
),
|
||||
'et_pb_wc_upsells_no_image' => array(
|
||||
'show_image' => 'off',
|
||||
),
|
||||
'et_pb_wc_upsells_no_price' => array(
|
||||
'show_price' => 'off',
|
||||
),
|
||||
'et_pb_wc_upsells_no_rating' => array(
|
||||
'show_rating' => 'off',
|
||||
),
|
||||
'et_pb_wc_upsells_no_sale_badge' => array(
|
||||
'show_sale_badge' => 'off',
|
||||
),
|
||||
),
|
||||
),
|
||||
false,
|
||||
null,
|
||||
true
|
||||
);
|
||||
|
||||
if ( $multi_view_attrs && is_array( $multi_view_attrs ) ) {
|
||||
$outer_wrapper_attrs = array_merge( $outer_wrapper_attrs, $multi_view_attrs );
|
||||
}
|
||||
|
||||
return $outer_wrapper_attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the module output.
|
||||
*
|
||||
@ -668,6 +889,14 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
2
|
||||
);
|
||||
|
||||
add_filter(
|
||||
"et_builder_module_{$render_slug}_outer_wrapper_attrs",
|
||||
array(
|
||||
$this,
|
||||
'add_multi_view_attrs',
|
||||
)
|
||||
);
|
||||
|
||||
$output = $this->_render_module_wrapper( $output, $render_slug );
|
||||
|
||||
remove_filter(
|
||||
|
Reference in New Issue
Block a user