Plugin Directory

Changeset 2331126


Ignore:
Timestamp:
06/26/2020 08:43:23 AM (6 years ago)
Author:
ashour
Message:

adjust the timezone check

Location:
woo-sale-countdown/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • woo-sale-countdown/trunk/assets/js/actions.js

    r2330521 r2331126  
    55
    66        if ( WCSC_ajax_data.stillValid && null !== WCSC_ajax_data.endDate ) {
    7             var startTime    = new Date( WCSC_ajax_data.currentDate );
    8             var FlipDownTime = new Date( WCSC_ajax_data.endDate );
    9             $('.wcsc-product-countdown-timer').FlipClock( ( FlipDownTime.getTime() - startTime.getTime() ) / 1000, {
     7            $('.wcsc-product-countdown-timer').FlipClock( ( WCSC_ajax_data.endDate - WCSC_ajax_data.currentDate ), {
    108                clockFace: 'DailyCounter',
    119                countdown: true,
  • woo-sale-countdown/trunk/settings.php

    r2330747 r2331126  
    8282         */
    8383        public $stock_color;
    84 
    85         /**
    86          * Time Zone.
    87          *
    88          * @var int.
    89          */
    90         public $time_zone;
    9184
    9285        /**
     
    179172            $sale_date = $product_due_date_obj->date_i18n( 'Y-m-d H:i:s' );
    180173            if ( 'back' === $side ) {
    181                 $timezone  = (int) get_option( WCSC_PREFIX . '_timezone', 0 );
    182                 $time_zone = $timezone > 0 ? -$timezone : abs( $timezone );
    183                 $sale_date = date( 'Y-m-d H:i:s', strtotime( $sale_date ) + ( $time_zone * MINUTE_IN_SECONDS ) );
     174                $sale_date = date( 'Y-m-d H:i:s', strtotime( $sale_date ) );
    184175            }
    185176
  • woo-sale-countdown/trunk/woo-sale-countdown.php

    r2331100 r2331126  
    124124                    'ajaxUrl'     => admin_url( 'admin-ajax.php' ),
    125125                    'nonce'       => wp_create_nonce( WCSC_PREFIX . '_nonce' ),
    126                     'currentDate' => gmdate( 'm/d/y H:i:s' ),
    127                     'endDate'     => $this->is_sale_valid ? gmdate( 'm/d/y H:i:s', strtotime( $this->settings->get_product_sale_time( 'to', 'front' ) ) ) : null,
     126                    'currentDate' => current_time( 'timestamp', false ),
     127                    'endDate'     => $this->is_sale_valid ? strtotime( $this->settings->get_product_sale_time( 'to', 'front' ), current_time( 'timestamp', false ) ) : null,
    128128                )
    129129            );
     
    224224            // Check if sale to is bigger than current time.
    225225            if ( ! empty( $product->get_date_on_sale_to() ) ) {
    226                 if ( strtotime( $product->get_date_on_sale_to()->format( 'Y-m-d H:i:s' ) ) <= strtotime( gmdate( 'Y-m-d H:i' ) ) ) {
     226                if ( strtotime( $product->get_date_on_sale_to()->format( 'Y-m-d H:i:s' ) ) <= strtotime( date( 'Y-m-d H:i' ) ) ) {
    227227                    update_post_meta( $product->get_id(), '_price', $product->get_regular_price( 'edit' ) );
    228228                    $regular_price = $product->get_regular_price();
     
    232232                    $product->set_date_on_sale_from( '' );
    233233                    $product->save();
    234                 } elseif ( strtotime( $product->get_date_on_sale_to()->format( 'Y-m-d H:i:s' ) ) > strtotime( gmdate( 'Y-m-d H:i' ) ) ) {
     234                } elseif ( strtotime( $product->get_date_on_sale_to()->format( 'Y-m-d H:i:s' ) ) > strtotime( date( 'Y-m-d H:i' ) ) ) {
    235235                    add_filter( 'woocommerce_product_is_on_sale', array( $this, 'filter_is_on_sale' ), 1000, 2 );
    236236
Note: See TracChangeset for help on using the changeset viewer.