P?@?@83?@ R@8G@P$b@$b@XT@HS@XFO@XFO@`A@JX@؅G@0FO@$b@K@r^@؅G@3?@83?@G@G@ K@HT@8G@#b@#b@8G@ʞͦUh]@?@`Y@HT@@{H@^^0µc@Bc^^HµcXµc@8 d^^pµcµc@D@^^µc^µcµc@?{H@__µc@pOc__õc õc@pc__8õcPõc_hõc@D@__õc_õcõc]cµc]õc õcõc@{H@bb ĵc@ 1cbb8ĵcHĵc@PBcbb`ĵcxĵcbĵc@cbbĵcbĵcĵcX ȾcccõcĵcƵc ŵc@{H@ccPŵc@Bccchŵcxŵc@T!b@ccŵc@T!b@ccŵc@Tpb@ccŵc@V8nJ@cc Ƶc cƵc8ƵccŵcŵcHƵccŵc`ƵcEXdct [ ], 'exclude' => [ ], 'excludeCategory' => [ ], 'excludeTag' => [ ] ]; // var_dump($args); foreach ( $_normalize as $key => $value ) { $args[ $key ] = ! empty( $args[ $key ] ) ? implode( ',', $this->get_array_column( $args[ $key ], 'value' ) ) : $value; } // Set Orderby to Default if Pro Orderby is selected and Pro isn't active $proOrderby = [ 'rand' ]; if ( isset( $args[ 'orderby' ] ) && ! ESSENTIAL_BLOCKS_IS_PRO_ACTIVE && in_array( $args[ 'orderby' ], $proOrderby ) ) { $args[ 'orderby' ] = 'date'; } $args = wp_parse_args( $args, [ 'per_page' => 10, 'offset' => 0 ] ); if ( "related_products" === $query_type ) { $product = json_decode( $args[ "product" ], true ); $product_id = isset( $product[ "value" ] ) && "current" !== $product[ "value" ] ? $product[ "value" ] : get_the_ID(); $per_page = $args[ 'per_page' ]; $exclude_products = isset( $args[ 'exclude_products' ] ) ? Helper::get_value_from_json_array( json_decode( $args[ 'exclude_products' ], true ) ) : [ ]; $related_products = wc_get_related_products( $product_id, $args[ 'per_page' ], $exclude_products ); unset( $args ); $args[ 'post__in' ] = is_array( $related_products ) && count( $related_products ) > 0 ? $related_products : [ ]; $args[ 'per_page' ] = $per_page; } $isCustomCartBtn = $_essential_attributes[ 'isCustomCartBtn' ]; $simpleCartText = $_essential_attributes[ 'simpleCartText' ]; $variableCartText = $_essential_attributes[ 'variableCartText' ]; $groupedCartText = $_essential_attributes[ 'groupedCartText' ]; $externalCartText = $_essential_attributes[ 'externalCartText' ]; $defaultCartText = $_essential_attributes[ 'defaultCartText' ]; $this->sampleData = [ $simpleCartText, $variableCartText, $groupedCartText, $externalCartText, $defaultCartText ]; if ( $isCustomCartBtn ) { // change the cart button text according to editor change add_filter( 'woocommerce_product_add_to_cart_text', [ $this, 'eb_change_cart_button_text' ], 10, 1 ); } $query = new WP_Query( Product::query_builder( $args ) ); $blockId = isset( $attributes[ 'blockId' ] ) ? $attributes[ 'blockId' ] : ''; $classHook = isset( $attributes[ 'classHook' ] ) ? $attributes[ 'classHook' ] : ''; //Handle loadMoreOptions $loadMoreOptions = [ ]; if ( isset( $attributes[ 'loadMoreOptions' ] ) ) { $loadMoreOptions = $attributes[ 'loadMoreOptions' ]; $loadMoreOptions[ 'totalPosts' ] = $query->found_posts ?? 0; } $_essential_attributes[ 'loadMoreOptions' ] = $loadMoreOptions; ob_start(); Helper::views( 'product-grid', array_merge( $_essential_attributes, [ 'blockId' => $blockId, 'classHook' => $classHook, 'query' => isset( $query ) ? $query : '', 'essentialAttr' => $_essential_attributes, 'loadMoreOptions' => $loadMoreOptions, 'queryData' => $args ] ) ); if ( $isCustomCartBtn ) { // remove our own callback from filter remove_filter( 'woocommerce_product_add_to_cart_text', [ $this, 'eb_change_cart_button_text' ], 10 ); } return ob_get_clean(); } public function eb_change_cart_button_text( $text ) { global $product; list( $simpleCartText, $variableCartText, $groupedCartText, $externalCartText, $defaultCartText ) = $this->sampleData; $product_type = $product->get_type(); $product_types = [ 'external' => $externalCartText, 'grouped' => $groupedCartText, 'simple' => $simpleCartText, 'variable' => $variableCartText ]; return isset( $product_types[ $product_type ] ) ? esc_html( $product_types[ $product_type ] ) : esc_html( $defaultCartText ); } }