additional_actions = new SingleProductAdditionalActions(); new WooCommerceAddToCart(); } public function render_layout($args = []) { $args = wp_parse_args( $args, [ 'layout' => null, 'defaults' => null, 'exclude' => null ] ); if (! $args['defaults']) { throw new Error('No defaults provided'); } if (! $args['layout']) { $args['layout'] = blocksy_get_theme_mod( 'woo_single_layout', blocksy_get_woo_single_layout_defaults() ); } if ($args['defaults']) { $args['layout'] = blocksy_normalize_layout( $args['layout'], $args['defaults'] ); } // TODO: maybe to refactor if ($args['exclude']) { $exclude_column_ids = array_column($args['exclude'], 'id'); $args['layout'] = array_filter($args['layout'], function($layer) use ($exclude_column_ids) { return ! in_array($layer['id'], $exclude_column_ids); }); } $args['layout'] = apply_filters( 'blocksy:woocommerce:product-single:layout', $args['layout'] ); foreach ($args['layout'] as $layer) { if (! $layer['enabled']) { continue; } if (method_exists($this, $layer['id'])) { $this->{$layer['id']}($layer); continue; } do_action('blocksy:woocommerce:product:custom:layer', $layer); } } public function product_title($layer) { do_action('blocksy:woocommerce:product-single:title:before'); woocommerce_template_single_title(); do_action('blocksy:woocommerce:product-single:title:after'); } public function product_rating($layer) { do_action('blocksy:woocommerce:product-single:rating:before'); woocommerce_template_single_rating(); do_action('blocksy:woocommerce:product-single:rating:after'); } public function product_price($layer) { do_action('blocksy:woocommerce:product-single:price:before'); woocommerce_template_single_price(); do_action('blocksy:woocommerce:product-single:price:after'); } public function product_desc($layer) { do_action('blocksy:woocommerce:product-single:excerpt:before'); woocommerce_template_single_excerpt(); do_action('blocksy:woocommerce:product-single:excerpt:after'); } public function divider($layer) { echo blocksy_html_tag( 'span', [ 'class' => 'ct-product-divider', 'data-id' => blocksy_akg('__id', $layer, 'default') ], '' ); } public function product_add_to_cart($layer) { do_action('blocksy:woocommerce:product-single:add_to_cart:before'); $section_title = blocksy_akg('add_to_cart_layer_title', $layer, ''); ob_start(); woocommerce_template_single_add_to_cart(); $single_add_to_cart = ob_get_clean(); echo blocksy_html_tag( 'div', [ 'class' => 'ct-product-add-to-cart', ], ( ! empty($section_title) || is_customize_preview() ? blocksy_html_tag( 'span', [ 'class' => 'ct-module-title', ], $section_title ) : '' ) . $single_add_to_cart ); do_action('blocksy:woocommerce:product-single:add_to_cart:after'); } public function product_meta($layer) { do_action('blocksy:woocommerce:product-single:meta:before'); woocommerce_template_single_meta(); do_action('blocksy:woocommerce:product-single:meta:after'); } public function product_payment_methods($layer) { $items = [ [ 'id' => 'item_mastercard', 'enabled' => true, 'label' => 'Mastercard' ], [ 'id' => 'item_visa', 'enabled' => true, 'label' => 'Visa' ], [ 'id' => 'item_amex', 'enabled' => true, 'label' => 'Amex' ], [ 'id' => 'item_discover', 'enabled' => true, 'label' => 'Discover' ], ]; if (isset($layer['payment_items'])) { $items = $layer['payment_items']; } if (! count($items)) { return; } $data_color = blocksy_akg('payment_icons_color', $layer, 'default'); $section_title = blocksy_akg('payment_methods_title', $layer, __('Guaranteed Safe Checkout', 'blocksy')); $out = '
'; $out .= '' . $section_title . ''; $icons = [ 'item_mastercard' => ' ', 'item_visa' => ' ', 'item_amex' => ' ', 'item_discover' => ' ', 'item_paypal' => ' ', 'item_apple_pay' => ' ', 'item_google_pay' => ' ', 'custom_link' => '', ]; foreach ($items as $key => $item) { if ($item['enabled']) { $icon = blocksy_html_tag( 'span', [ 'class' => 'ct-icon-container' ], $icons[$item['id']] ); if ( isset($item['icon_source']) && $item['icon_source'] === 'custom' && function_exists('blc_get_icon') ) { $icon = blc_get_icon( [ 'icon_descriptor' => blocksy_akg('icon', $item, [ 'icon' => "blc blc-user" // TODO: get defaults from item ID ]) ] ); } $out .= $icon; } } $out .= '
'; echo $out; } public function additional_info($layer) { $items = [ [ 'id' => 'additional_info_item', 'enabled' => true, 'item_title' => __('Premium Quality', 'blocksy'), ], [ 'id' => 'additional_info_item', 'enabled' => true, 'item_title' => __('Secure Payments', 'blocksy'), ], [ 'id' => 'additional_info_item', 'enabled' => true, 'item_title' => __('Satisfaction Guarantee', 'blocksy') ], [ 'id' => 'additional_info_item', 'enabled' => true, 'item_title' => __('Worldwide Shipping', 'blocksy') ], [ 'id' => 'additional_info_item', 'enabled' => true, 'item_title' => __('Money Back Guarantee', 'blocksy') ], ]; if (isset($layer['additional_info_items'])) { $items = $layer['additional_info_items']; } if (! count($items)) { return; } $section_title = __('Extra Features', 'blocksy'); if (isset($layer['product_additional_info_title'])) { $section_title = $layer['product_additional_info_title']; } $out = '
'; $out .= '' . $section_title . ''; $out .= ''; $out .= '
'; echo $out; } }