Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   <div class="rq-car-listing-wrapper">
  2.     <#
  3.         if(data.view === 'grid'){
  4.             var wrapperClass = 'rq-listing-grid-two';
  5.         }else{
  6.             var wrapperClass = 'rq-listing-list-two';
  7.         }
  8.  
  9.         var urlData = data.urlData;
  10.  
  11.         /**
  12.          * Calculate Total Price
  13.          *
  14.          * @since 2.0.0
  15.          * @return number
  16.          */
  17.         function rnb_calculate_total_price(rnb_data){
  18.             var pricingData = rnb_data.pricings,
  19.                 conditionalData = rnb_data.settings.conditions,
  20.                 resources = rnb_data.resources,
  21.                 pickup_locations = rnb_data.locations.pickup ? rnb_data.locations.pickup : '',
  22.                 return_locations = rnb_data.locations.return ? rnb_data.locations.return : '';
  23.  
  24.             var totalDays = 1;
  25.             var startDate;
  26.             var endDate;
  27.             var price;
  28.             var cost = 0;
  29.             var dynamicPrice = 0;
  30.  
  31.             if ('datepickerrange' in urlData ) {
  32.                 var dates = urlData.datepickerrange,
  33.                     splitDates = dates[0].split('-'),
  34.                     sDate =splitDates[0],
  35.                     eDate = splitDates[1];
  36.  
  37.                 var selected_resources = urlData.tex_resource ? urlData.tex_resource : '',
  38.                     selected_dropoff_locations = urlData.tex_dropoff_location ? urlData.tex_dropoff_location : '',
  39.                     selected_pickup_locations = urlData.tex_pickup_location ? urlData.tex_pickup_location : '';
  40.  
  41.                 var splitSDate= sDate.split('_'),
  42.                     startDate = splitSDate[2]+'-'+splitSDate[0]+'-'+splitSDate[1];
  43.  
  44.                 var splitEDate= eDate.split('_'),
  45.                     endDate = splitEDate[2]+'-'+splitEDate[0]+'-'+splitEDate[1];
  46.  
  47.                 var startTime = urlData.start_time ? urlData.start_time : '';
  48.                 var endTime = urlData.end_time ? urlData.end_time : '';
  49.  
  50.                 var pickupDateTime = startDate + ' ' +startTime,
  51.                     dropoffDateTime = endDate + ' ' +endTime;
  52.  
  53.  
  54.                 var start = new Date(pickupDateTime),
  55.                     end   = new Date(dropoffDateTime),
  56.                     diff  = end.getTime() - start.getTime(),
  57.                     hours = diff/3600000,
  58.                     days,total_hours;
  59.  
  60.                 var singleDayBooking = conditionalData.single_day_booking;
  61.  
  62.                 if(hours < 24){
  63.                     if(singleDayBooking == 'open'){
  64.                         days = 1;
  65.                     }else{
  66.                         days = 0;
  67.                         total_hours = Math.ceil(hours);
  68.                     }
  69.                 }else{
  70.                     days = parseInt(hours/24);
  71.                     var extra_hours = hours%24;
  72.                     if(singleDayBooking == 'open'){
  73.                         if(extra_hours >= parseFloat(conditionalData.max_time_late) ){
  74.                             days = days + 1;
  75.                         }
  76.                     }else{
  77.                         if(extra_hours > parseFloat(conditionalData.max_time_late) ){
  78.                             days = days + 1;
  79.                         }
  80.                     }
  81.                 }
  82.  
  83.                 totalDays = days;
  84.  
  85.  
  86.                 /**
  87.                  * Get resources
  88.                  *
  89.                  * @since 1.0.0
  90.                  * @return null
  91.                  */
  92.                 var resource_items = resources.map( (item, index) => {
  93.                     if(selected_resources.includes(item.resource_slug)){
  94.                         return item;
  95.                     }
  96.                     return false;
  97.                 } );
  98.  
  99.                 var payable_resources = resource_items.filter( item => item !== false);
  100.  
  101.  
  102.                 /**
  103.                  * Get Pickup Locations
  104.                  *
  105.                  * @since 1.0.0
  106.                  * @return null
  107.                  */
  108.                 var p_locations = pickup_locations.map( (location, index) => {
  109.                     if(selected_pickup_locations.includes(location.slug)){
  110.                         return location;
  111.                     }
  112.                     return false;
  113.                 } );
  114.  
  115.                 var payable_pickup_locations = p_locations.filter( location => location !== false);
  116.  
  117.  
  118.                 /**
  119.                  * Get Return Locations
  120.                  *
  121.                  * @since 1.0.0
  122.                  * @return null
  123.                  */
  124.                 var r_locations = return_locations.map( (location, index) => {
  125.                     if(selected_dropoff_locations.includes(location.slug)){
  126.                         return location;
  127.                     }
  128.                     return false;
  129.                 } );
  130.  
  131.                 var payable_return_locations = r_locations.filter( location => location !== false);
  132.  
  133.  
  134.                 /**
  135.                  * Calculate general pricing
  136.                  *
  137.                  * @since 1.0.0
  138.                  * @return null
  139.                  */
  140.                 if (pricingData.pricing_type === 'general_pricing') {
  141.                     var cost = rnb_calculate_general_price(cost, pricingData, totalDays, payable_resources, payable_pickup_locations, payable_return_locations);
  142.                 }
  143.  
  144.  
  145.                 /**
  146.                 * Calculate day ranges pricing
  147.                 *
  148.                 * @since 1.0.0
  149.                 * @return null
  150.                 */
  151.                 if (pricingData.pricing_type === 'days_range') {
  152.                     var cost = rnb_calculate_days_range_price(cost, pricingData, totalDays, payable_resources, payable_pickup_locations, payable_return_locations);
  153.                 }
  154.  
  155.  
  156.                 /**
  157.                 * Calculate daily pricing
  158.                 *
  159.                 * @since 1.0.0
  160.                 * @return null
  161.                 */
  162.                 if (pricingData.pricing_type === 'daily_pricing') {
  163.                     var cost = rnb_calculate_daily_price(cost, pricingData, totalDays, startDate, payable_resources, payable_pickup_locations, payable_return_locations);
  164.                 }
  165.  
  166.  
  167.                 /**
  168.                 * Calculate monthly pricing
  169.                 *
  170.                 * @since 1.0.0
  171.                 * @return null
  172.                 */
  173.                 if (pricingData.pricing_type === 'monthly_pricing') {
  174.                     var cost = rnb_calculate_monthly_price(cost, pricingData, totalDays, startDate, payable_resources, payable_pickup_locations, payable_return_locations);
  175.                 }
  176.             }
  177.  
  178.             return cost;
  179.         }
  180.  
  181.         /**
  182.          * Calculate resources and person cost
  183.          *
  184.          * @since 1.0.0
  185.          * @return number
  186.          */
  187.         function calculate_third_party_cost(cost, days, resources, pickup_locations, return_locations){
  188.  
  189.             console.log(resources, pickup_locations, return_locations);
  190.  
  191.             if(pickup_locations.length != 0){
  192.                 pickup_locations.forEach(function(value, index){
  193.                     cost = parseFloat(cost) + parseFloat(value.cost);
  194.                 });
  195.             }
  196.  
  197.             if(return_locations.length != 0){
  198.                 return_locations.forEach(function(value, index){
  199.                     cost = parseFloat(cost) + parseFloat(value.cost);
  200.                 });
  201.             }
  202.  
  203.             if(resources.length != 0){
  204.                 resources.forEach(function(value, index){
  205.                     if(value.resource_applicable == 'per_day'){
  206.                         var resource_cost = value.resource_cost ? value.resource_cost : 0;
  207.                         cost = parseFloat(cost) + parseInt(days)*parseFloat(resource_cost);
  208.                     }else{
  209.                         var resource_cost = value.resource_cost ? value.resource_cost : 0;
  210.                         cost = parseFloat(cost) + parseFloat(resource_cost);
  211.                     }
  212.                 });
  213.             }
  214.  
  215.             return cost;
  216.         }
  217.  
  218.         /**
  219.          * Calculate price discount
  220.          *
  221.          * @since 1.0.0
  222.          * @return number
  223.          */
  224.         function calculatePriceDiscount(totalDays, cost, priceDiscount){
  225.  
  226.             var flag = 0;
  227.             var discountAmount;
  228.             var discountType;
  229.  
  230.             priceDiscount.forEach(function (value, index) {
  231.                 if (flag === 0){
  232.                     if (parseInt(value.min_days, 10) <= parseInt(totalDays, 10) && parseInt(value.max_days, 10) >= parseInt(totalDays, 10)){
  233.                         discountType = value.discount_type;
  234.                         discountAmount = value.discount_amount;
  235.                         flag = 1;
  236.                     }
  237.                 }
  238.             });
  239.  
  240.             if (discountType !== undefined && discountType && discountAmount !== undefined && discountAmount) {
  241.                 if (discountType === 'percentage'){
  242.                      cost = cost - (cost*discountAmount)/100;
  243.                 } else {
  244.                     cost = cost - discountAmount;
  245.                 }
  246.             }
  247.             return cost;
  248.         }
  249.  
  250.         /**
  251.          * Calculate General Price
  252.          *
  253.          * @since 2.0.0
  254.          * @return number
  255.          */
  256.         function rnb_calculate_general_price(cost, pricingData, totalDays, payable_resources, payable_pickup_locations, payable_return_locations){
  257.             price = pricingData.general_pricing;
  258.             cost = price * totalDays;
  259.             dynamicPrice = price;
  260.  
  261.             var priceDiscount = pricingData.price_discount;
  262.             cost = calculatePriceDiscount(totalDays, cost, priceDiscount);
  263.             cost = calculate_third_party_cost(cost, totalDays, payable_resources, payable_pickup_locations, payable_return_locations);
  264.             return cost;
  265.         }
  266.  
  267.         /**
  268.          * Calculate Day Ranges Price
  269.          *
  270.          * @since 2.0.0
  271.          * @return number
  272.          */
  273.         function rnb_calculate_days_range_price(cost, pricingData, totalDays, payable_resources, payable_pickup_locations, payable_return_locations){
  274.             var daysRangePricing = pricingData.days_range;
  275.             price = daysRangePricing[daysRangePricing.length - 1].range_cost;
  276.             var flag = 0;
  277.  
  278.             daysRangePricing.forEach(function (value, index) {
  279.                 if (flag === 0) {
  280.                     if (value.cost_applicable === 'per_day') {
  281.                         if (parseInt(value.min_days, 10) <= parseInt(totalDays, 10) && parseInt(value.max_days, 10) >= parseInt(totalDays, 10)) {
  282.                             cost = parseFloat(value.range_cost) * parseInt(totalDays, 10);
  283.                             flag = 1;
  284.                             dynamicPrice = parseFloat(value.range_cost);
  285.                         }
  286.                     } else {
  287.                         if (parseInt(value.min_days, 10) <= parseInt(totalDays, 10) && parseInt(value.max_days, 10) >= parseInt(totalDays, 10)) {
  288.                             cost = parseFloat(value.range_cost);
  289.                             flag = 1;
  290.                             dynamicPrice = parseFloat(value.range_cost);
  291.                         }
  292.                     }
  293.                 }
  294.             });
  295.             var priceDiscount = pricingData.price_discount;
  296.             cost = calculatePriceDiscount(totalDays, cost, priceDiscount);
  297.             cost = calculate_third_party_cost(cost, totalDays, payable_resources, payable_pickup_locations, payable_return_locations);
  298.             return cost;
  299.         }
  300.  
  301.         /**
  302.          * Calculate Daily Price
  303.          *
  304.          * @since 2.0.0
  305.          * @return number
  306.          */
  307.         function rnb_calculate_daily_price(cost, pricingData, totalDays, startDate, payable_resources, payable_pickup_locations, payable_return_locations){
  308.             if (totalDays > 0) {
  309.                 const dailyPricingPlan = pricingData.daily_pricing;
  310.                 let day;
  311.  
  312.                 for (let i = 0; i < parseInt(totalDays, 10); i++) {
  313.                     if (i === 0) {
  314.                         const start = new Date(startDate);
  315.                         day = start.getDay();
  316.                     } else {
  317.                         const tomorrow = new Date(startDate);
  318.                         const nextDay = tomorrow.setDate(tomorrow.getDate() + i);
  319.                         const convertDate = new Date(nextDay);
  320.                         day = convertDate.getDay();
  321.                     }
  322.                     switch (day) {
  323.                         case 0:
  324.                             if (dailyPricingPlan.sunday !== '') {
  325.                                 cost = cost + parseFloat(dailyPricingPlan.sunday);
  326.                                 if (i === 0) {
  327.                                     dynamicPrice = parseFloat(dailyPricingPlan.sunday);
  328.                                 }
  329.                             } else {
  330.                                 cost = cost + 0;
  331.                             }
  332.                             break;
  333.                         case 1:
  334.                             if (dailyPricingPlan.monday !== '') {
  335.                                 cost = cost + parseFloat(dailyPricingPlan.monday);
  336.                                 if (i === 0) {
  337.                                     dynamicPrice = parseFloat(dailyPricingPlan.monday);
  338.                                 }
  339.                             } else {
  340.                                 cost = cost + 0;
  341.                             }
  342.                             break;
  343.                         case 2:
  344.                             if (dailyPricingPlan.tuesday !== '') {
  345.                                 cost = cost + parseFloat(dailyPricingPlan.tuesday);
  346.                                 if (i === 0) {
  347.                                     dynamicPrice = parseFloat(dailyPricingPlan.tuesday);
  348.                                 }
  349.                             } else {
  350.                                 cost = cost + 0;
  351.                             }
  352.                             break;
  353.                         case 3:
  354.                             if (dailyPricingPlan.wednesday !== '') {
  355.                                 cost = cost + parseFloat(dailyPricingPlan.wednesday);
  356.                                 if (i === 0) {
  357.                                     dynamicPrice = parseFloat(dailyPricingPlan.wednesday);
  358.                                 }
  359.                             } else {
  360.                                 cost = cost + 0;
  361.                             }
  362.                             break;
  363.                         case 4:
  364.                             if (dailyPricingPlan.thursday !== '') {
  365.                                 cost = cost + parseFloat(dailyPricingPlan.thursday);
  366.                                 if (i === 0) {
  367.                                     dynamicPrice = parseFloat(dailyPricingPlan.thursday);
  368.                                 }
  369.                             } else {
  370.                                 cost = cost + 0;
  371.                             }
  372.                             break;
  373.                         case 5:
  374.                             if (dailyPricingPlan.friday !== '') {
  375.                                 cost = cost + parseFloat(dailyPricingPlan.friday);
  376.                                 if (i === 0) {
  377.                                     dynamicPrice = parseFloat(dailyPricingPlan.friday);
  378.                                 }
  379.                             } else {
  380.                                 cost = cost + 0;
  381.                             }
  382.                             break;
  383.                         case 6:
  384.                             if (dailyPricingPlan.saturday !== '') {
  385.                                 cost = cost + parseFloat(dailyPricingPlan.saturday);
  386.                                 if (i === 0) {
  387.                                     dynamicPrice = parseFloat(dailyPricingPlan.saturday);
  388.                                 }
  389.                             } else {
  390.                                 cost = cost + 0;
  391.                             }
  392.                             break;
  393.                         default:
  394.                             break;
  395.                     }
  396.                 }
  397.                 const priceDiscount = pricingData.price_discount;
  398.                 cost = calculatePriceDiscount(totalDays, cost, priceDiscount);
  399.                 cost = calculate_third_party_cost(cost, totalDays, payable_resources, payable_pickup_locations, payable_return_locations);
  400.                 return cost;
  401.             }
  402.         }
  403.  
  404.         /**
  405.          * Calculate Monthly Price
  406.          *
  407.          * @since 2.0.0
  408.          * @return number
  409.          */
  410.         function rnb_calculate_monthly_price(cost, pricingData, totalDays, startDate, payable_resources, payable_pickup_locations, payable_return_locations) {
  411.             if (totalDays > 0) {
  412.                 const monthlyPricingPlan = pricingData.monthly_pricing;
  413.                 let month;
  414.  
  415.                 for (let i = 0; i < parseInt(totalDays, 10); i++) {
  416.                     if (i === 0) {
  417.                         const start = new Date(startDate);
  418.                         month = start.getMonth();
  419.                     } else {
  420.                         const tomorrow = new Date(startDate);
  421.                         const nextDay = tomorrow.setDate(tomorrow.getDate() + i);
  422.                         const convertDate = new Date(nextDay);
  423.                         month = convertDate.getMonth();
  424.                     }
  425.                     //End if-else statement
  426.                     switch (month) {
  427.                         case 0:
  428.                             if (monthlyPricingPlan.january !== '') {
  429.                                 cost = cost + parseFloat(monthlyPricingPlan.january);
  430.                                 if (i === 0) {
  431.                                     dynamicPrice = parseFloat(monthlyPricingPlan.january);
  432.                                 }
  433.                             } else {
  434.                                 cost = cost + 0;
  435.                             }
  436.                             break;
  437.                         case 1:
  438.                             if (monthlyPricingPlan.february !== '') {
  439.                                 cost = cost + parseFloat(monthlyPricingPlan.february);
  440.                                 if (i === 0) {
  441.                                     dynamicPrice = parseFloat(monthlyPricingPlan.february);
  442.                                 }
  443.                             } else {
  444.                                 cost = cost + 0;
  445.                             }
  446.                             break;
  447.                         case 2:
  448.                             if (monthlyPricingPlan.march !== '') {
  449.                                 cost = cost + parseFloat(monthlyPricingPlan.march);
  450.                                 if (i === 0) {
  451.                                     dynamicPrice = parseFloat(monthlyPricingPlan.march);
  452.                                 }
  453.                             } else {
  454.                                  cost = cost + 0;
  455.                             }
  456.                             break;
  457.                         case 3:
  458.                             if (monthlyPricingPlan.april !== '') {
  459.                                 cost = cost + parseFloat(monthlyPricingPlan.april);
  460.                                 if (i === 0) {
  461.                                     dynamicPrice = parseFloat(monthlyPricingPlan.april);
  462.                                 }
  463.                             } else {
  464.                                 cost = cost + 0;
  465.                             }
  466.                             break;
  467.                         case 4:
  468.                             if (monthlyPricingPlan.may !== '') {
  469.                                 cost = cost + parseFloat(monthlyPricingPlan.may);
  470.                                 if (i === 0) {
  471.                                     dynamicPrice = parseFloat(monthlyPricingPlan.may);
  472.                                 }
  473.                             } else {
  474.                                 cost = cost + 0;
  475.                             }
  476.                             break;
  477.                         case 5:
  478.                             if (monthlyPricingPlan.june !== '') {
  479.                                 cost = cost + parseFloat(monthlyPricingPlan.june);
  480.                                 if (i === 0) {
  481.                                     dynamicPrice = parseFloat(monthlyPricingPlan.june);
  482.                                 }
  483.                             } else {
  484.                                 cost = cost + 0;
  485.                             }
  486.                             break;
  487.                         case 6:
  488.                             if (monthlyPricingPlan.july !== '') {
  489.                                 cost = cost + parseFloat(monthlyPricingPlan.july);
  490.                                 if (i === 0) {
  491.                                     dynamicPrice = parseFloat(monthlyPricingPlan.july);
  492.                                 }
  493.                             } else {
  494.                                 cost = cost + 0;
  495.                             }
  496.                             break;
  497.                         case 7:
  498.                             if (monthlyPricingPlan.august !== '') {
  499.                                 cost = cost + parseFloat(monthlyPricingPlan.august);
  500.                                 if (i === 0) {
  501.                                     dynamicPrice = parseFloat(monthlyPricingPlan.august);
  502.                                 }
  503.                             } else {
  504.                                 cost = cost + 0;
  505.                             }
  506.                             break;
  507.                         case 8:
  508.                             if (monthlyPricingPlan.september !== '') {
  509.                                 cost = cost + parseFloat(monthlyPricingPlan.september);
  510.                                 if (i === 0) {
  511.                                     dynamicPrice = parseFloat(monthlyPricingPlan.september);
  512.                                 }
  513.                             } else {
  514.                                 cost = cost + 0;
  515.                             }
  516.                             break;
  517.                         case 9:
  518.                             if (monthlyPricingPlan.october !== '') {
  519.                                 cost = cost + parseFloat(monthlyPricingPlan.october);
  520.                                 if (i === 0) {
  521.                                     dynamicPrice = parseFloat(monthlyPricingPlan.october);
  522.                                 }
  523.                             } else {
  524.                                 cost = cost + 0;
  525.                             }
  526.                             break;
  527.                         case 10:
  528.                             if (monthlyPricingPlan.november !== '') {
  529.                                 cost = cost + parseFloat(monthlyPricingPlan.november);
  530.                                 if (i === 0) {
  531.                                     dynamicPrice = parseFloat(monthlyPricingPlan.november);
  532.                                 }
  533.                             } else {
  534.                                 cost = cost + 0;
  535.                             }
  536.                             break;
  537.                         case 11:
  538.                             if (monthlyPricingPlan.december !== '') {
  539.                                 cost = cost + parseFloat(monthlyPricingPlan.december);
  540.                                 if (i === 0) {
  541.                                     dynamicPrice = parseFloat(monthlyPricingPlan.december);
  542.                                 }
  543.                             } else {
  544.                                 cost = cost + 0;
  545.                             }
  546.                             break;
  547.                         default:
  548.                             break;
  549.                     }
  550.                     //End Switch
  551.                 }
  552.                 const priceDiscount = pricingData.price_discount;
  553.                 cost = calculatePriceDiscount(totalDays, cost, priceDiscount);
  554.                 cost = calculate_third_party_cost(cost, totalDays, payable_resources, payable_pickup_locations, payable_return_locations);
  555.             }
  556.             return cost;
  557.         }
  558.  
  559.         function rnb_generate_final_url(productBaseUrl){
  560.             const searchUrl = window.location.href;
  561.             const uniqueKeyValues = searchUrl.split(/[?&]/).reduce(function (a, b, c) {
  562.                 const p = b.split('='), k = p[0], v = decodeURIComponent(p[1]);
  563.                 if (!p[1]) return a;
  564.                 a[k] = a[k] || [];
  565.                 a[k].push(v);
  566.                 return a;
  567.             }, {});
  568.  
  569.  
  570.             let sep = '&';
  571.             let finalUrl='';
  572.             let value;
  573.  
  574.             for (let key in uniqueKeyValues) {
  575.                 value = uniqueKeyValues[key];
  576.                 finalUrl += key + "=" + value.toString()+sep;
  577.             }
  578.  
  579.             finalUrl = '?'+finalUrl;
  580.             finalUrl = productBaseUrl+finalUrl;
  581.  
  582.             return finalUrl;
  583.         }
  584.  
  585.     #>
  586.     <div class="rq-listing-choose {{wrapperClass}}">
  587.         <div class="row">
  588.             <# if(data.view === 'grid') { #>
  589.                 <# _.each(data.posts, function( post ) { #>
  590.                 <#
  591.                     const rnb_data = JSON.parse(post.meta._redq_rental_all_data);
  592.                     console.log(rnb_data);
  593.                     let totalCost = rnb_calculate_total_price(rnb_data);
  594.                     totalCost = totalCost !== 0 ? totalCost : post.meta._price;
  595.                     const productBaseUrl = post.post_link;
  596.                     const finalUrl = rnb_generate_final_url(productBaseUrl);
  597.                 #>
  598.                 <div class="col-md-6 col-sm-6">
  599.                     <div class="listing-single">
  600.                         <div class="listing-img">
  601.                             <img src={{ post.thumb_url }} alt="">
  602.                             <div class="listing-image-hover">
  603.                                 <a href="{{finalUrl}}">Book Now</a>
  604.                             </div>
  605.                         </div>
  606.                         <div class="listing-details-two">
  607.                             <h3 class="listing-title"><a href="{{finalUrl}}">{{post.post_title}}</a></h3>
  608.                             <div class="listing-meta-content">
  609.                                 <div class="reactiveRatingPro">
  610.                                     <# _.each([1,2,3,4,5], function( num ) { #>
  611.                                         <# if(num <= parseFloat(post.meta._wc_average_rating, 10)) { #>
  612.                                             <span class="star ratingOne"></span>
  613.                                         <# } else if((num > parseFloat(post.meta._wc_average_rating, 10)) && ((num-1 < parseFloat(post.meta._wc_average_rating, 10)))) { #>
  614.                                             <span class="star ratingHalf"></span>
  615.                                         <# } else { #>
  616.                                             <span class="star ratingNone"></span>
  617.                                         <# } #>
  618.                                     <# }) #>
  619.                                 </div>
  620.                                 <span><span class="price">${{post.meta._price}}</span>/Day</span>
  621.                             </div>
  622.                             <div class="listing-attributes">
  623.                                 <#
  624.                                     const attributes = rnb_data.attributes ? rnb_data.attributes : {};
  625.                                     const highlighted_attrs = attributes.highlighted ? attributes.highlighted : false;
  626.                                 #>
  627.                                 <# if( highlighted_attrs && highlighted_attrs.length > 0) { #>
  628.                                 <ul>
  629.                                     <# _.each(highlighted_attrs, function( attribute, index ) { #>
  630.                                     <li>{{attribute.name}}<span>{{attribute.value}}</span></li>
  631.                                     <# }); #>
  632.                                 </ul>
  633.                                 <# } #>
  634.                             </div>
  635.                             <div class="listing-footer">
  636.                                 <span class="book-now-text"><span class="price"><span class='total-text'>Total </span>${{parseFloat(totalCost).toFixed(2)}}</span></span>
  637.                                 <span class="book-now-btn"><a href="{{finalUrl}}">Book Now</a></span>
  638.                             </div>
  639.                         </div>
  640.                     </div>
  641.                 </div>
  642.                 <# }); #>
  643.             <# }else{ #>
  644.                 <# _.each(data.posts, function( post ) { #>
  645.                 <#
  646.                     const rnb_data = JSON.parse(post.meta._redq_rental_all_data);
  647.                     let totalCost = rnb_calculate_total_price(rnb_data);
  648.                     totalCost = totalCost !== 0 ? totalCost : post.meta._price;
  649.                     const productBaseUrl = post.post_link;
  650.                     const finalUrl = rnb_generate_final_url(productBaseUrl);
  651.                    // post.post_link = finalUrl;
  652.                 #>
  653.                 <div class="col-md-12 col-sm-12">
  654.                     <div class="listing-single">
  655.                         <div class="listing-img">
  656.                             <img src={{ post.thumb_url }} alt="" pagespeed_url_hash="744447902" onload="pagespeed.CriticalImages.checkImageForCriticality(this);">
  657.                         </div>
  658.                         <div class="listing-details">
  659.                           <div class="listing-details-title">
  660.                             <h3 class="car-name"><a href="{{post.post_link}}">{{post.post_title}}</a></h3>
  661.                               <span >$
  662.                                     <span class="price">{{post.meta._price}}</span> / day
  663.                                 </span>
  664.                             </div>
  665.                             <div class="reactiveRatingPro">
  666.                                 <# _.each([1,2,3,4,5], function( num ) { #>
  667.                                     <# if(num <= parseFloat(post.meta._wc_average_rating, 10)) { #>
  668.                                         <span class="star ratingOne"></span>
  669.                                     <# } else if((num > parseFloat(post.meta._wc_average_rating, 10)) && ((num-1 < parseFloat(post.meta._wc_average_rating, 10)))) { #>
  670.                                         <span class="star ratingHalf"></span>
  671.                                     <# } else { #>
  672.                                         <span class="star ratingNone"></span>
  673.                                     <# } #>
  674.                                 <# }) #>
  675.                                 <span class='rating-text'>{{post.meta._wc_review_count}} <# if(post.meta._wc_review_count <= 1) { #> Comment <# }else{ #> Comments <# } #></span>
  676.                             </div>
  677.                             <#
  678.                                 const attributes = rnb_data.attributes ? rnb_data.attributes : {};
  679.                                 const highlighted_attrs = attributes.highlighted ? attributes.highlighted : false;
  680.                             #>
  681.                             <# if( highlighted_attrs && highlighted_attrs.length > 0) { #>
  682.                             <ul class='listing-attribute'>
  683.                                 <# _.each(highlighted_attrs, function( attribute, index ) { #>
  684.                                 <li>{{attribute.name}} <span>{{attribute.value}}</span></li>
  685.                                 <# }); #>
  686.                             </ul>
  687.                             <# } #>
  688.  
  689.                             <#
  690.                                 const features = rnb_data.features ? rnb_data.features : {};
  691.                                 const highlighted_features = features.highlighted ? features.highlighted : false;
  692.                             #>
  693.                             <# if( highlighted_features && highlighted_features.length > 0) { #>
  694.                             <ul class='listing-feature'>
  695.                                 <# _.each(highlighted_features, function( feature, index ) { #>
  696.                                 <li class='list-feature-item'>{{feature.name}}</li>
  697.                                 <# }); #>
  698.                             </ul>
  699.                             <# } #>
  700.  
  701.                             <div class="listing-footer">
  702.                                 <span>
  703.                                     Total Cost <span class="price">{{parseFloat(totalCost).toFixed(2)}}</span> $
  704.                                 </span>
  705.                                 <div class='btn-wrapper'>
  706.                                     <span class='details-btn'><a href="{{post.post_link}}">Details</a></span>
  707.                                     <span class='book-now-btn'><a href="{{post.post_link}}">Book Now</a></span>
  708.                                 </div>
  709.                             </div>
  710.  
  711.                         </div>
  712.                     </div>
  713.                 </div>
  714.                 <# }); #>
  715.             <# } #>
  716.         </div>
  717.     </div>
  718. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement