assets
3 years ago
comparison-cookie.php
3 years ago
comparison-field-value.php
3 years ago
comparison-helper.php
3 years ago
comparison-share.php
3 years ago
comparison.php
3 years ago
group-meta.php
3 years ago
route.php
3 years ago
comparison-share.php
40 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace ShopEngine\Modules\Comparison; |
| 5 | |
| 6 | |
| 7 | class Comparison_Share { |
| 8 | |
| 9 | public static function init() { |
| 10 | $product_ids = isset( $_GET['product_ids'] ) && $_GET['product_ids'] ? explode( ',', $_GET['product_ids'] ?? '' ) : []; |
| 11 | |
| 12 | if ( empty( $product_ids ) ) { |
| 13 | $existing_comparison_products = empty( $_COOKIE[ Comparison::COOKIE_KEY ] ) ? '' : $_COOKIE[ Comparison::COOKIE_KEY ]; |
| 14 | $product_ids = $existing_comparison_products? explode( ',', $existing_comparison_products ) : []; |
| 15 | |
| 16 | } else { |
| 17 | setcookie( |
| 18 | Comparison::COOKIE_KEY, |
| 19 | implode( ',', $product_ids ), |
| 20 | strtotime( '+' . Comparison::COOKIE_TIME_IN_DAYS . ' days' ), '/' |
| 21 | ); |
| 22 | } |
| 23 | |
| 24 | get_header(); |
| 25 | ?> |
| 26 | <div class="shopengine-comparison-page"> |
| 27 | <div class="comparison-page-inner"> |
| 28 | <?php |
| 29 | if ( empty( $product_ids ) ) { |
| 30 | echo '<h1 class="shopengine-no-comparison-product">' . esc_html__( 'No product is added for comparison, please add some product to compare', 'shopengine' ) . '</h1>'; |
| 31 | } else { |
| 32 | Comparison_Helper::get_html( $product_ids, true ); |
| 33 | } |
| 34 | ?> |
| 35 | </div> |
| 36 | </div> |
| 37 | <?php get_footer(); |
| 38 | } |
| 39 | |
| 40 | } |