ASTRA_Ext_WooCommerce_Markup::recently_viewed_html()

Recently Viewed HTML


Description


Return

(void)


Source

File: addons/woocommerce/classes/class-astra-ext-woocommerce-markup.php

		public function recently_viewed_html() {

			global $post;

			$number_of_products      = astra_get_option( 'single-product-related-upsell-per-page' );
			$recently_viewed_heading = astra_get_option( 'single-product-recently-viewed-text' );

			if ( empty( $_COOKIE['woocommerce_recently_viewed'] ) ) { // @codingStandardsIgnoreLine.
				$viewed_products = array();
			} else {
				$viewed_products = wp_parse_id_list( (array) explode( '|', wp_unslash( $_COOKIE['woocommerce_recently_viewed'] ) ) ); // @codingStandardsIgnoreLine.
			}

			if ( empty( $viewed_products ) ) {
				return;
			}

			$keys = array_flip( $viewed_products );

			if ( isset( $keys[ $post->ID ] ) ) {
				unset( $viewed_products[ $keys[ $post->ID ] ] );
			}

			$title       = '<h2>' . esc_html( $recently_viewed_heading ) . '</h2>';
			$product_ids = implode( ',', array_reverse( $viewed_products ) );

			echo wp_kses_post( $title . do_shortcode( "[products ids='$product_ids' orderby='post__in' limit='$number_of_products']" ) );
		}

Changelog

Changelog
Version Description
3.9.3 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.