Plugin Directory

Changeset 3340928


Ignore:
Timestamp:
08/07/2025 11:22:24 AM (8 months ago)
Author:
teamzt
Message:

Fix the shoppable highlight issue that occurs when the event is manually ended.

Location:
mylivecart
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mylivecart/tags/1.0.4/assets/js/zt-script.js

    r3321848 r3340928  
    1010jQuery(document).ready(
    1111    function () {
     12        let shoppaproductList = jQuery('#product_list').data('product-list');
    1213        jQuery(".zt-loader").hide();
    1314        jQuery("#auth_form i.dashicons").on(
     
    105106                    if (productID == product_id) {
    106107                        console.log('Product_id', product_id);
    107                        
     108
    108109                        jQuery(this).attr('style', 'display: block !important');
    109                         console.log(jQuery(this)); 
     110                        console.log(jQuery(this));
    110111                        jQuery('.highlight_product_separator').show();
    111112                        jQuery(".product_list_section").css('max-height', 'calc(90% - 180px)');
     
    119120                jQuery('.highlight_product_separator').hide();
    120121                jQuery(".product_list_section").css('max-height', '90%');
    121             }
    122         }
    123 
    124 //          function shopable_highlight(){
    125 //          const productList =  jQuery('#product_list').data('product-list');
    126 //          console.log(productList);
    127 
    128 //          setInterval(()=>{
    129 //              productList.forEach((item)=>{
    130 //                  const highlightTime = item.highlight_time;
    131 //                  const date = new Date();
    132 //                  const currDate = date.toLocaleDateString('en-GB');
    133 //                  const currTime = date.toLocaleTimeString('en-GB');
    134 
    135 //                  const highDate = new Date(highlightTime).toLocaleDateString('en-GB');
    136 //                  const highTime = new Date(highlightTime).toLocaleTimeString('en-GB');
    137 //                  if(currDate === highDate && currTime >= highTime){
    138 //                      jQuery('.hide_product_card').each(function () {
    139 //                                              var product_id = jQuery(this).attr('product_id');
    140 //                                              let event_id = jQuery(this).attr('event_id');
    141 
    142 //                                              if (item.product_id == product_id) {
    143 //                                                  //jQuery(".high_light_product").show();
    144 //                                                  jQuery(this).show();
    145 //                                                  jQuery('.highlight_product_separator').show();
    146 //                                                  jQuery(".product_list_section").css('max-height', 'calc(90% - 180px)');
    147 //                                              } else {
    148 //                                                  jQuery(this).hide();
    149 //                                                  // jQuery('.highlight_product_separator').hide();
    150 //                                              }
    151 
    152 //                                          });
    153 //                  }
    154                    
    155 
    156 //              });
    157 //          },1000);
    158 
    159 //          }
    160 
    161 
    162 function shopable_highlight() {
    163             const productList = jQuery('#product_list').data('product-list');
     122
     123            }
     124        }
     125
     126        //          function shopable_highlight(){
     127        //          const productList =  jQuery('#product_list').data('product-list');
     128        //          console.log(productList);
     129
     130        //          setInterval(()=>{
     131        //              productList.forEach((item)=>{
     132        //                  const highlightTime = item.highlight_time;
     133        //                  const date = new Date();
     134        //                  const currDate = date.toLocaleDateString('en-GB');
     135        //                  const currTime = date.toLocaleTimeString('en-GB');
     136
     137        //                  const highDate = new Date(highlightTime).toLocaleDateString('en-GB');
     138        //                  const highTime = new Date(highlightTime).toLocaleTimeString('en-GB');
     139        //                  if(currDate === highDate && currTime >= highTime){
     140        //                      jQuery('.hide_product_card').each(function () {
     141        //                                              var product_id = jQuery(this).attr('product_id');
     142        //                                              let event_id = jQuery(this).attr('event_id');
     143
     144        //                                              if (item.product_id == product_id) {
     145        //                                                  //jQuery(".high_light_product").show();
     146        //                                                  jQuery(this).show();
     147        //                                                  jQuery('.highlight_product_separator').show();
     148        //                                                  jQuery(".product_list_section").css('max-height', 'calc(90% - 180px)');
     149        //                                              } else {
     150        //                                                  jQuery(this).hide();
     151        //                                                  // jQuery('.highlight_product_separator').hide();
     152        //                                              }
     153
     154        //                                          });
     155        //                  }
     156
     157
     158        //              });
     159        //          },1000);
     160
     161        //          }
     162
     163
     164        function shopable_highlight() {
     165
    164166            const event_type = jQuery('#product_list').data('event-type');
    165             if(event_type != 1){
    166                     setInterval(() => {
    167                         const now = new Date();
    168 
    169                         productList.forEach((item) => {
    170                             const highlightStart = new Date(item.highlight_time);
    171                             const highlightEnd = new Date(item.highlight_end_time);
    172 
    173                             const isActive = now >= highlightStart && now <= highlightEnd;
    174 
    175                             jQuery('.hide_product_card').each(function () {
    176                                 const product_id = jQuery(this).attr('product_id');
    177 
    178                                 if (item.product_id == product_id) {
    179                                     const isCurrentlyVisible = jQuery(this).is(':visible');
    180 
    181                                     if (isActive && !isCurrentlyVisible) {
    182                                         jQuery(this).show();
    183                                         jQuery('.highlight_product_separator').show();
    184                                         jQuery(".product_list_section").css('max-height', 'calc(90% - 180px)');
    185                                     }
    186 
    187                                     if (!isActive && isCurrentlyVisible) {
    188                                         jQuery(this).hide();
    189                                         jQuery('.hide_product_card').hide();
    190                                         jQuery('.highlight_product_separator').hide();
    191                                         jQuery(".product_list_section").css('max-height', '90%');
    192                                     }
     167            if (event_type != 1) {
     168
     169                setInterval(() => {
     170                    const now = new Date();
     171
     172                    shoppaproductList.forEach((item) => {
     173                        const highlightStart = new Date(item.highlight_time);
     174                        const highlightEnd = new Date(item.highlight_end_time);
     175
     176                        const isActive = now >= highlightStart && now <= highlightEnd;
     177
     178                        jQuery('.hide_product_card').each(function () {
     179                            const product_id = jQuery(this).attr('product_id');
     180
     181                            if (item.product_id == product_id) {
     182                                const isCurrentlyVisible = jQuery(this).is(':visible');
     183
     184                                if (isActive && !isCurrentlyVisible) {
     185                                    jQuery(this).show();
     186                                    jQuery('.highlight_product_separator').show();
     187                                    jQuery(".product_list_section").css('max-height', 'calc(90% - 180px)');
    193188                                }
    194                             });
     189
     190                                if (!isActive && isCurrentlyVisible) {
     191                                    jQuery(this).hide();
     192                                    jQuery('.hide_product_card').hide();
     193                                    jQuery('.highlight_product_separator').hide();
     194                                    jQuery(".product_list_section").css('max-height', '90%');
     195                                }
     196                            }
    195197                        });
     198                    });
    196199                }, 1000);
    197                
    198             }
    199            
    200         }
    201 
    202        
     200
     201            }
     202
     203        }
     204
     205
    203206
    204207        function hideProductCards() {
     
    225228        }
    226229
    227 //      const navigateToEListHandler = () => {
    228 //          try {
    229 //              // Construct the redirect URL safely
    230 //              if (ztcbl_qv && ztcbl_qv.ztcbl_site_url) {
    231 //                  const redirectUrl = `${ztcbl_qv.ztcbl_site_url}/events-list`;
    232 
    233 //                  // Optional: Log for debugging or analytics purposes
    234 //                  console.log('Navigating to:', redirectUrl);
    235 
    236 //                  // Perform the redirection
    237 //                  window.location.href = redirectUrl;
    238 //              } else {
    239 //                  console.error('ztcbl_site_url is not defined.');
    240 //              }
    241 //          } catch (error) {
    242 //              // Handle any potential errors gracefully
    243 //              console.error('Error during redirection:', error);
    244 //          } finally {
    245 //              // Optionally remove the event listener to avoid multiple redirects
    246 //              socket.off('navigateToEList', navigateToEListHandler);
    247 //          }
    248 //      };
     230        //      const navigateToEListHandler = () => {
     231        //          try {
     232        //              // Construct the redirect URL safely
     233        //              if (ztcbl_qv && ztcbl_qv.ztcbl_site_url) {
     234        //                  const redirectUrl = `${ztcbl_qv.ztcbl_site_url}/events-list`;
     235
     236        //                  // Optional: Log for debugging or analytics purposes
     237        //                  console.log('Navigating to:', redirectUrl);
     238
     239        //                  // Perform the redirection
     240        //                  window.location.href = redirectUrl;
     241        //              } else {
     242        //                  console.error('ztcbl_site_url is not defined.');
     243        //              }
     244        //          } catch (error) {
     245        //              // Handle any potential errors gracefully
     246        //              console.error('Error during redirection:', error);
     247        //          } finally {
     248        //              // Optionally remove the event listener to avoid multiple redirects
     249        //              socket.off('navigateToEList', navigateToEListHandler);
     250        //          }
     251        //      };
    249252
    250253        function connectHighlightedSocket() {
     
    253256            socket.on('connect', () => {
    254257                console.log('Connection Succesfull through wordpress');
    255                 socket.emit('joinRoom', { room: eventKey, type:'wordpress' });
    256             });
    257 
    258 
    259 socket.on('watcherJoined', (data)=>{
    260 //  console.log(data);
    261 });
     258                socket.emit('joinRoom', { room: eventKey, type: 'wordpress' });
     259            });
     260
     261
     262            socket.on('watcherJoined', (data) => {
     263                //  console.log(data);
     264            });
    262265            socket.on('highlighted', (data) => {
     266                console.log(data);
    263267                let eventKey = data.eventKey;
    264268                let urlKey = getEventKey();
     
    266270                if (eventKey === urlKey) {
    267271                    if (data.highlited === 'null') {
     272                        const event_type = jQuery('#product_list').data('event-type');
     273                        if (event_type != 1) shoppaproductList = [];
    268274                        hideProductCards();
    269275                    } else {
     
    275281                }
    276282            });
    277        
     283
    278284
    279285            socket.on('disconnect', () => {
     
    11451151        const data = await response.json();
    11461152        jQuery('#ztcbl_sent_button').removeClass('loading');
    1147         jQuery('#feedback-message').css('display','block');
     1153        jQuery('#feedback-message').css('display', 'block');
    11481154        jQuery('#feedback-message').text(data?.message);
    11491155        setTimeout(() => {
  • mylivecart/trunk/assets/js/zt-script.js

    r3321848 r3340928  
    1010jQuery(document).ready(
    1111    function () {
     12        let shoppaproductList = jQuery('#product_list').data('product-list');
    1213        jQuery(".zt-loader").hide();
    1314        jQuery("#auth_form i.dashicons").on(
     
    105106                    if (productID == product_id) {
    106107                        console.log('Product_id', product_id);
    107                        
     108
    108109                        jQuery(this).attr('style', 'display: block !important');
    109                         console.log(jQuery(this)); 
     110                        console.log(jQuery(this));
    110111                        jQuery('.highlight_product_separator').show();
    111112                        jQuery(".product_list_section").css('max-height', 'calc(90% - 180px)');
     
    119120                jQuery('.highlight_product_separator').hide();
    120121                jQuery(".product_list_section").css('max-height', '90%');
    121             }
    122         }
    123 
    124 //          function shopable_highlight(){
    125 //          const productList =  jQuery('#product_list').data('product-list');
    126 //          console.log(productList);
    127 
    128 //          setInterval(()=>{
    129 //              productList.forEach((item)=>{
    130 //                  const highlightTime = item.highlight_time;
    131 //                  const date = new Date();
    132 //                  const currDate = date.toLocaleDateString('en-GB');
    133 //                  const currTime = date.toLocaleTimeString('en-GB');
    134 
    135 //                  const highDate = new Date(highlightTime).toLocaleDateString('en-GB');
    136 //                  const highTime = new Date(highlightTime).toLocaleTimeString('en-GB');
    137 //                  if(currDate === highDate && currTime >= highTime){
    138 //                      jQuery('.hide_product_card').each(function () {
    139 //                                              var product_id = jQuery(this).attr('product_id');
    140 //                                              let event_id = jQuery(this).attr('event_id');
    141 
    142 //                                              if (item.product_id == product_id) {
    143 //                                                  //jQuery(".high_light_product").show();
    144 //                                                  jQuery(this).show();
    145 //                                                  jQuery('.highlight_product_separator').show();
    146 //                                                  jQuery(".product_list_section").css('max-height', 'calc(90% - 180px)');
    147 //                                              } else {
    148 //                                                  jQuery(this).hide();
    149 //                                                  // jQuery('.highlight_product_separator').hide();
    150 //                                              }
    151 
    152 //                                          });
    153 //                  }
    154                    
    155 
    156 //              });
    157 //          },1000);
    158 
    159 //          }
    160 
    161 
    162 function shopable_highlight() {
    163             const productList = jQuery('#product_list').data('product-list');
     122
     123            }
     124        }
     125
     126        //          function shopable_highlight(){
     127        //          const productList =  jQuery('#product_list').data('product-list');
     128        //          console.log(productList);
     129
     130        //          setInterval(()=>{
     131        //              productList.forEach((item)=>{
     132        //                  const highlightTime = item.highlight_time;
     133        //                  const date = new Date();
     134        //                  const currDate = date.toLocaleDateString('en-GB');
     135        //                  const currTime = date.toLocaleTimeString('en-GB');
     136
     137        //                  const highDate = new Date(highlightTime).toLocaleDateString('en-GB');
     138        //                  const highTime = new Date(highlightTime).toLocaleTimeString('en-GB');
     139        //                  if(currDate === highDate && currTime >= highTime){
     140        //                      jQuery('.hide_product_card').each(function () {
     141        //                                              var product_id = jQuery(this).attr('product_id');
     142        //                                              let event_id = jQuery(this).attr('event_id');
     143
     144        //                                              if (item.product_id == product_id) {
     145        //                                                  //jQuery(".high_light_product").show();
     146        //                                                  jQuery(this).show();
     147        //                                                  jQuery('.highlight_product_separator').show();
     148        //                                                  jQuery(".product_list_section").css('max-height', 'calc(90% - 180px)');
     149        //                                              } else {
     150        //                                                  jQuery(this).hide();
     151        //                                                  // jQuery('.highlight_product_separator').hide();
     152        //                                              }
     153
     154        //                                          });
     155        //                  }
     156
     157
     158        //              });
     159        //          },1000);
     160
     161        //          }
     162
     163
     164        function shopable_highlight() {
     165
    164166            const event_type = jQuery('#product_list').data('event-type');
    165             if(event_type != 1){
    166                     setInterval(() => {
    167                         const now = new Date();
    168 
    169                         productList.forEach((item) => {
    170                             const highlightStart = new Date(item.highlight_time);
    171                             const highlightEnd = new Date(item.highlight_end_time);
    172 
    173                             const isActive = now >= highlightStart && now <= highlightEnd;
    174 
    175                             jQuery('.hide_product_card').each(function () {
    176                                 const product_id = jQuery(this).attr('product_id');
    177 
    178                                 if (item.product_id == product_id) {
    179                                     const isCurrentlyVisible = jQuery(this).is(':visible');
    180 
    181                                     if (isActive && !isCurrentlyVisible) {
    182                                         jQuery(this).show();
    183                                         jQuery('.highlight_product_separator').show();
    184                                         jQuery(".product_list_section").css('max-height', 'calc(90% - 180px)');
    185                                     }
    186 
    187                                     if (!isActive && isCurrentlyVisible) {
    188                                         jQuery(this).hide();
    189                                         jQuery('.hide_product_card').hide();
    190                                         jQuery('.highlight_product_separator').hide();
    191                                         jQuery(".product_list_section").css('max-height', '90%');
    192                                     }
     167            if (event_type != 1) {
     168
     169                setInterval(() => {
     170                    const now = new Date();
     171
     172                    shoppaproductList.forEach((item) => {
     173                        const highlightStart = new Date(item.highlight_time);
     174                        const highlightEnd = new Date(item.highlight_end_time);
     175
     176                        const isActive = now >= highlightStart && now <= highlightEnd;
     177
     178                        jQuery('.hide_product_card').each(function () {
     179                            const product_id = jQuery(this).attr('product_id');
     180
     181                            if (item.product_id == product_id) {
     182                                const isCurrentlyVisible = jQuery(this).is(':visible');
     183
     184                                if (isActive && !isCurrentlyVisible) {
     185                                    jQuery(this).show();
     186                                    jQuery('.highlight_product_separator').show();
     187                                    jQuery(".product_list_section").css('max-height', 'calc(90% - 180px)');
    193188                                }
    194                             });
     189
     190                                if (!isActive && isCurrentlyVisible) {
     191                                    jQuery(this).hide();
     192                                    jQuery('.hide_product_card').hide();
     193                                    jQuery('.highlight_product_separator').hide();
     194                                    jQuery(".product_list_section").css('max-height', '90%');
     195                                }
     196                            }
    195197                        });
     198                    });
    196199                }, 1000);
    197                
    198             }
    199            
    200         }
    201 
    202        
     200
     201            }
     202
     203        }
     204
     205
    203206
    204207        function hideProductCards() {
     
    225228        }
    226229
    227 //      const navigateToEListHandler = () => {
    228 //          try {
    229 //              // Construct the redirect URL safely
    230 //              if (ztcbl_qv && ztcbl_qv.ztcbl_site_url) {
    231 //                  const redirectUrl = `${ztcbl_qv.ztcbl_site_url}/events-list`;
    232 
    233 //                  // Optional: Log for debugging or analytics purposes
    234 //                  console.log('Navigating to:', redirectUrl);
    235 
    236 //                  // Perform the redirection
    237 //                  window.location.href = redirectUrl;
    238 //              } else {
    239 //                  console.error('ztcbl_site_url is not defined.');
    240 //              }
    241 //          } catch (error) {
    242 //              // Handle any potential errors gracefully
    243 //              console.error('Error during redirection:', error);
    244 //          } finally {
    245 //              // Optionally remove the event listener to avoid multiple redirects
    246 //              socket.off('navigateToEList', navigateToEListHandler);
    247 //          }
    248 //      };
     230        //      const navigateToEListHandler = () => {
     231        //          try {
     232        //              // Construct the redirect URL safely
     233        //              if (ztcbl_qv && ztcbl_qv.ztcbl_site_url) {
     234        //                  const redirectUrl = `${ztcbl_qv.ztcbl_site_url}/events-list`;
     235
     236        //                  // Optional: Log for debugging or analytics purposes
     237        //                  console.log('Navigating to:', redirectUrl);
     238
     239        //                  // Perform the redirection
     240        //                  window.location.href = redirectUrl;
     241        //              } else {
     242        //                  console.error('ztcbl_site_url is not defined.');
     243        //              }
     244        //          } catch (error) {
     245        //              // Handle any potential errors gracefully
     246        //              console.error('Error during redirection:', error);
     247        //          } finally {
     248        //              // Optionally remove the event listener to avoid multiple redirects
     249        //              socket.off('navigateToEList', navigateToEListHandler);
     250        //          }
     251        //      };
    249252
    250253        function connectHighlightedSocket() {
     
    253256            socket.on('connect', () => {
    254257                console.log('Connection Succesfull through wordpress');
    255                 socket.emit('joinRoom', { room: eventKey, type:'wordpress' });
    256             });
    257 
    258 
    259 socket.on('watcherJoined', (data)=>{
    260 //  console.log(data);
    261 });
     258                socket.emit('joinRoom', { room: eventKey, type: 'wordpress' });
     259            });
     260
     261
     262            socket.on('watcherJoined', (data) => {
     263                //  console.log(data);
     264            });
    262265            socket.on('highlighted', (data) => {
     266                console.log(data);
    263267                let eventKey = data.eventKey;
    264268                let urlKey = getEventKey();
     
    266270                if (eventKey === urlKey) {
    267271                    if (data.highlited === 'null') {
     272                        const event_type = jQuery('#product_list').data('event-type');
     273                        if (event_type != 1) shoppaproductList = [];
    268274                        hideProductCards();
    269275                    } else {
     
    275281                }
    276282            });
    277        
     283
    278284
    279285            socket.on('disconnect', () => {
     
    11451151        const data = await response.json();
    11461152        jQuery('#ztcbl_sent_button').removeClass('loading');
    1147         jQuery('#feedback-message').css('display','block');
     1153        jQuery('#feedback-message').css('display', 'block');
    11481154        jQuery('#feedback-message').text(data?.message);
    11491155        setTimeout(() => {
Note: See TracChangeset for help on using the changeset viewer.