How to programmatically change delivery date on Bigcommerce Order - javascript

I'm using ajax to add a Saturday delivery surcharge on my bigcommerce site. Basically, I'm adding the surcharge as another product when a Sat delivery date is clicked:
$.ajax({type:"GET", url:"http://www.url.com/cart.php?action=add&product_id=138", success: function(text)
The problem we noticed is that this method changed the delivery date of the entire order to the current date. The product itself doesn't have its own delivery date.
I tried to rectify this by adding "delivery_date" and "deliveryDate" (from the xml product export) to the ajax call, but it resulted in nothing.
Here's an example order export:
<orders>
<order>
<Order_ID><![CDATA[358]]></Order_ID>
<Customer_ID><![CDATA[0]]></Customer_ID>
<Customer_Name><![CDATA[]]></Customer_Name>
<Customer_Email><![CDATA[]]></Customer_Email>
<Customer_Phone><![CDATA[]]></Customer_Phone>
<Order_Date><![CDATA[11/05/2016]]></Order_Date>
<Order_Status><![CDATA[Awaiting Payment]]></Order_Status>
<Subtotal_inc_tax><![CDATA[140.00]]></Subtotal_inc_tax>
<Subtotal_ex_tax><![CDATA[140.00]]></Subtotal_ex_tax>
<Tax_Total><![CDATA[0.00]]></Tax_Total>
<Shipping_Cost_inc_tax><![CDATA[0.00]]></Shipping_Cost_inc_tax>
<Shipping_Cost_ex_tax><![CDATA[0.00]]></Shipping_Cost_ex_tax>
<Ship_Method><![CDATA[Free Shipping]]></Ship_Method>
<Handling_Cost_inc_tax><![CDATA[0.0000]]></Handling_Cost_inc_tax>
<Handling_Cost_ex_tax><![CDATA[0.0000]]></Handling_Cost_ex_tax>
<Order_Total_inc_tax><![CDATA[140.00]]></Order_Total_inc_tax>
<Order_Total_ex_tax><![CDATA[140.00]]></Order_Total_ex_tax>
<Payment_Method><![CDATA[Pay in Store]]></Payment_Method>
<Total_Quantity><![CDATA[2]]></Total_Quantity>
<Total_Shipped><![CDATA[0]]></Total_Shipped>
<Date_Shipped><![CDATA[]]></Date_Shipped>
<Order_Currency_Code><![CDATA[USD]]></Order_Currency_Code>
<Exchange_Rate><![CDATA[1.0000000000]]></Exchange_Rate>
<Order_Notes><![CDATA[]]></Order_Notes>
<Customer_Message><![CDATA[]]></Customer_Message>
<Billing_First_Name><![CDATA[f]]></Billing_First_Name>
<Billing_Last_Name><![CDATA[f]]></Billing_Last_Name>
<Billing_Company><![CDATA[ Traveler]]></Billing_Company>
<Billing_Street_1><![CDATA[That Road]]></Billing_Street_1>
<Billing_Street_2><![CDATA[That Road]]></Billing_Street_2>
<Billing_Suburb><![CDATA[San Fran]]></Billing_Suburb>
<Billing_State><![CDATA[CA]]></Billing_State>
<Billing_Zip><![CDATA[1234567]]></Billing_Zip>
<Billing_Country><![CDATA[United States]]></Billing_Country>
<Billing_Phone><![CDATA[thah]]></Billing_Phone>
<Billing_Email><![CDATA[test#gmail.com]]></Billing_Email>
<Shipping_First_Name><![CDATA[d]]></Shipping_First_Name>
<Shipping_Last_Name><![CDATA[d]]></Shipping_Last_Name>
<Shipping_Company><![CDATA[Company]]></Shipping_Company>
<Shipping_Street_1><![CDATA[That Road]]></Shipping_Street_1>
<Shipping_Street_2><![CDATA[That Road]]></Shipping_Street_2>
<Shipping_Suburb><![CDATA[San Frab]]></Shipping_Suburb>
<Shipping_State><![CDATA[CA]]></Shipping_State>
<Shipping_Zip><![CDATA[1234567]]></Shipping_Zip>
<Shipping_Country><![CDATA[United States]]></Shipping_Country>
<Shipping_Phone><![CDATA[]]></Shipping_Phone>
<Shipping_Email><![CDATA[]]></Shipping_Email>
<Product_Details>
<item>
<Product_ID><![CDATA[86]]></Product_ID>
<Product_Qty><![CDATA[1]]></Product_Qty>
<Product_SKU><![CDATA[]]></Product_SKU>
<Product_Name><![CDATA[Lobster, Whole - Select]]></Product_Name>
<Product_Weight><![CDATA[1.0000]]></Product_Weight>
<Product_Variation_Details><![CDATA[Lobster, Whole - Select: 1 select lobster ($110), How do you want them prepared? Live (uncooked), Delivery Date: May 28th 2016]]></Product_Variation_Details>
<Product_Unit_Price><![CDATA[120.00]]></Product_Unit_Price>
<Product_Total_Price><![CDATA[120.00]]></Product_Total_Price>
</item>
<item>
<Product_ID><![CDATA[138]]></Product_ID>
<Product_Qty><![CDATA[1]]></Product_Qty>
<Product_SKU><![CDATA[]]></Product_SKU>
<Product_Name><![CDATA[Saturday Shipping Surcharge]]></Product_Name>
<Product_Weight><![CDATA[0.0000]]></Product_Weight>
<Product_Variation_Details><![CDATA[]]></Product_Variation_Details>
<Product_Unit_Price><![CDATA[20.00]]></Product_Unit_Price>
<Product_Total_Price><![CDATA[20.00]]></Product_Total_Price>
</item>
</Product_Details>
<Store_Credit_Redeemed><![CDATA[0.00]]></Store_Credit_Redeemed>
<Gift_Certificate_Amount_Redeemed><![CDATA[0.00]]></Gift_Certificate_Amount_Redeemed>
<Gift_Certificate_Code><![CDATA[]]></Gift_Certificate_Code>
<Gift_Certificate_Expiration_Date><![CDATA[]]></Gift_Certificate_Expiration_Date>
<Coupon_Details>
</Coupon_Details>
</order>
</orders>
So, the question is: is there any way to programmatically add a delivery date to a product or order? Or perhaps another way to keep it from changing the delivery date from the product the person is actually ordering?

Related

Add a row per day or week automatically for multiple years (w/ using script or function ?)

What I would like to do is to create a script or with a function that will add automatically the day, the month and the year per row for 4 years for example in order to make a calendar of shooting, pre production and post prod per film. It would be so long to do it manually and add each day per month for 4 or more years. If it's done by a script it would be done instantly and would be possible to update later to add more years.
Example of what I'm looking for
If it's too complicated per day, I can add per week. Like week 1 January 21, just like in the picture. But I really prefer if that's possible to add a row per day to be the most accurate as possible.
Days for the rest of the year in a column
function daysforrestofyear() {
let days = [];
let dt = new Date();
const ldtv = new Date(dt.getFullYear() + 1,0,1).valueOf();
do {
days.push([Utilities.formatDate(dt,Session.getScriptTimeZone(),"dd/MMM/yyyy")]);
dt.setDate(dt.getDate() + 1);
}while(dt.valueOf() < ldtv)
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName("Sheet0");
sh.clearContents();
sh.getRange(1,1,days.length,1).setValues(days);
}
Jun/04/2022
Jun/05/2022
Jun/06/2022
Jun/07/2022
Jun/08/2022
Jun/9/2022
Jun/10/2022
Jun/11/2022
Jun/12/2022
Jun/13/2022
Jun/14/2022
Jun/15/2022
Jun/16/2022
Jun/17/2022
Jun/18/2022
Jun/19/2022
Jun/20/2022
Jun/21/2022
Jun/22/2022
Jun/23/2022
Jun/24/2022
Jun/25/2022
Jun/26/2022
Jun/27/2022
Jun/28/2022
Jun/29/2022
Jun/30/2022
Jul/01/2022
Jul/02/2022
Jul/03/2022
Jul/04/2022
Jul/05/2022
Jul/06/2022
Jul/07/2022
Jul/08/2022
Jul/9/2022
Jul/10/2022
Jul/11/2022
Jul/12/2022
Jul/13/2022
Jul/14/2022
Jul/15/2022
Jul/16/2022
Jul/17/2022
Jul/18/2022
Jul/19/2022
Jul/20/2022
Jul/21/2022
Jul/22/2022
Jul/23/2022
Jul/24/2022
Jul/25/2022
Jul/26/2022
Jul/27/2022
Jul/28/2022
Jul/29/2022
Jul/30/2022
Jul/31/2022
Aug/01/2022
Aug/02/2022
Aug/03/2022
Aug/04/2022
Aug/05/2022
Aug/06/2022
Aug/07/2022
Aug/08/2022
Aug/9/2022
Aug/10/2022
Aug/11/2022
Aug/12/2022
Aug/13/2022
Aug/14/2022
Aug/15/2022
Aug/16/2022
Aug/17/2022
Aug/18/2022
Aug/19/2022
Aug/20/2022
Aug/21/2022
Aug/22/2022
Aug/23/2022
Aug/24/2022
Aug/25/2022
Aug/26/2022
Aug/27/2022
Aug/28/2022
Aug/29/2022
Aug/30/2022
Aug/31/2022
Sep/01/2022
Sep/02/2022
Sep/03/2022
Sep/04/2022
Sep/05/2022
Sep/06/2022
Sep/07/2022
Sep/08/2022
Sep/9/2022
Sep/10/2022
Sep/11/2022
Sep/12/2022
Sep/13/2022
Sep/14/2022
Sep/15/2022
Sep/16/2022
Sep/17/2022
Sep/18/2022
Sep/19/2022
Sep/20/2022
Sep/21/2022
Sep/22/2022
Sep/23/2022
Sep/24/2022
Sep/25/2022
Sep/26/2022
Sep/27/2022
Sep/28/2022
Sep/29/2022
Sep/30/2022
Oct/01/2022
Oct/02/2022
Oct/03/2022
Oct/04/2022
Oct/05/2022
Oct/06/2022
Oct/07/2022
Oct/08/2022
Oct/9/2022
Oct/10/2022
Oct/11/2022
Oct/12/2022
Oct/13/2022
Oct/14/2022
Oct/15/2022
Oct/16/2022
Oct/17/2022
Oct/18/2022
Oct/19/2022
Oct/20/2022
Oct/21/2022
Oct/22/2022
Oct/23/2022
Oct/24/2022
Oct/25/2022
Oct/26/2022
Oct/27/2022
Oct/28/2022
Oct/29/2022
Oct/30/2022
Oct/31/2022
Nov/01/2022
Nov/02/2022
Nov/03/2022
Nov/04/2022
Nov/05/2022
Nov/06/2022
Nov/07/2022
Nov/08/2022
Nov/9/2022
Nov/10/2022
Nov/11/2022
Nov/12/2022
Nov/13/2022
Nov/14/2022
Nov/15/2022
Nov/16/2022
Nov/17/2022
Nov/18/2022
Nov/19/2022
Nov/20/2022
Nov/21/2022
Nov/22/2022
Nov/23/2022
Nov/24/2022
Nov/25/2022
Nov/26/2022
Nov/27/2022
Nov/28/2022
Nov/29/2022
Nov/30/2022
Dec/01/2022
Dec/02/2022
Dec/03/2022
Dec/04/2022
Dec/05/2022
Dec/06/2022
Dec/07/2022
Dec/08/2022
Dec/9/2022
Dec/10/2022
Dec/11/2022
Dec/12/2022
Dec/13/2022
Dec/14/2022
Dec/15/2022
Dec/16/2022
Dec/17/2022
Dec/18/2022
Dec/19/2022
Dec/20/2022
Dec/21/2022
Dec/22/2022
Dec/23/2022
Dec/24/2022
Dec/25/2022
Dec/26/2022
Dec/27/2022
Dec/28/2022
Dec/29/2022
Dec/30/2022
Dec/31/2022

Quasar Q-Table how can I get the filtered or sorted rows?

I am get stucked ,I installed Quasar version 2.0.0 but it does not has a property to get the filtered or sorted rows.In previous versions of q-table it had a computedRows property but in the latest version it didn't
I am trying to add new features to the q-table like highlight focused row and enable keyboard features to allow in-line editing etc... so I need to know the row data(model) and its corresponding html row.
Quasar ver:2.0.0
Vuejs 3
Typescript
I found a temporary solution:
here is my q-table :
<template v-slot:body="props">
<q-tr
class="row-data"
:props="props"
:rowID="props.row.id"
>
<q-td
#click="onTdClick($event, props.row,
props.rowIndex, index)"
v-for="(col, index) in props.cols"
:key="col.name"
:props="props"
:column="col.name"
>
<slot :name="'column-' + col.name" :props="props" :row="props.row">
{{ col.value }}
</slot>
<slot
:name="'column-edit-' + col.name"
:props="props"
:row="props.row"
>
</slot>
</q-td>
</q-tr>
</template>
//Then I get the filtered rows by getting the displayed tr elements(each tr element has rowID attribute) :
getHtmlRows(): HTMLTableRowElement[] {
let htmlTable = this.getHtmlTable();
let htmlRows: HTMLTableRowElement[] = Array.from(
htmlTable.querySelectorAll("tr.row-data")
);
return htmlRows;
},
//If I want to get the row data corresponding to html row (tr) I used :
getRowData(id: number): any {
let table = this.$refs.qtableRef as QTable;
let rowData = table.rows?.find((rw) => rw.id == id);
return rowData;
},
getRowDataByHtmlRow(htmlRow: HTMLTableRowElement): any {
let rowID = htmlRow.getAttribute("rowID");
return this.getRowData(Number(rowID));
},
There's an undocumented way of accessing the computedRows and computedRowsNumber properties that I only found after extensive Google searching...
Give your table a ref: <q-table ref="table" />
Access these properties via the ref:
this.$refs.table.computedRows
this.$refs.table.computedRowsNumber
This was added in v2.0.0-beta.9 (March 8, 2021)
Explanation
computedRows -- gives you the displayed rows on current page
Example: if there are 30 results in total, but only 10 are shown in the current page, this will only return those 10 rows -- want them all? see filteredSortedRows
filteredSortedRows -- gives you ALL the displayed rows across all pages
Example: if there are 50 rows in total, but 30 rows match the filtered text and show up, and 10 rows are shown per page, this will return ALL those filtered 30 rows. If there's no filtered text, then this will return all those original 50 rows
computedRowsNumber -- gives you the length for the total displayed rows across all pages
same as filteredSortedRows.length
When server-side data fetching is enabled the properties above may behave differently. I had to check the source code to discover that, but haven't tested this in practice.
Source | Where I found it

how to reverse fetch images from nasa APOD api in react

** I fetched content from API with this code**
import React from "react";
import styles from "./Space.module.css";
import {useState,useEffect} from "react";
function Space() {
const [photoData,setPhotoData]=useState(null);
useEffect(()=>{
fetchPhoto();
async function fetchPhoto(){
const res = await fetch(`https://api.nasa.gov/planetary/apod?api_key=hETQq0FPsZJnUP9C3sUEFtwmJH3edb4I5bghfWDM`);
const data=await res.json();
setPhotoData(data);
console.log(data);
}
},[]); //empty array for running only once then empty array for that
if (!photoData) return <div />;
return (
<>
<div className={styles.space}>
{photoData.media_type === "image" ? (
<img
src={photoData.url}
alt={photoData.title}
className={styles.space}
/>
) : (
<iframe
title="space-video"
src={photoData.url}
frameBorder="0"
gesture="media"
allow="encrypted-media"
allowFullScreen
className={styles.space}
/>
)}
<div>
<h1>{photoData.title}</h1>
<p className={styles.space.date}>{photoData.date}</p>
<p className={styles.space.explanation}>{photoData.explanation}</p>
</div>
</div>
</>
);
}
export default Space;
and output of this code is like this
and I want Button here with next and then that will show previous day images
so can anyone tell me how to reverse that means after clicking on the next button by reversing the previous day images will show because NASA APOD(astronomy picture of the day )daily shown to all users like that is updated daily I know we can reverse that but can anyone tell me how to do that?
You can use date query parameter of apod api to get data for a specific date. This has default value today. Date needs to be in YYYY-MM-DD format. See apod section at https://api.nasa.gov/
If you want to request data for 2 January 2021 you'll have to send request to this :
https://api.nasa.gov/planetary/apod?date=2021-01-02&api_key=hETQq0FPsZJnUP9C3sUEFtwmJH3edb4I5bghfWDM
Note the date parameter
To get the previous day date use :
let today = new Date();
let yesterday = new Date();
yesterday.setDate(today.getDate() - 1);
console.log(yesterday.toString());
for formatting date in YYYY-MM-DD format see this question.
In onClick function of your button you'll make this http request and then change state with setPhotoData function.

html dynamically weather data insert to mysql with php

I have this dynamic link.
Every 10 minutes refresh new data from weather station.
I want to sent this data in mysql using php or javascript.
The html link have follow result:
imerominia="26/08/16";
ora="20:22";
sunriseTime=" 06:48";
sunsetTime="20:08";
ForecastStr=" Increasing clouds with little temperature change. Precipitation possible within 24 to 48 hrs.";
tempUnit="°C";
outsideTemp="27.3";
hiOutsideTemp="31.6";
hiOutsideTempAT="18:01";
lowOutsideTemp="20.8";
lowOutsideTempAT="00:32";
hiMonthlyOutsideTemp="36.7";
lowMonthlyOutsideTemp="13.4";
hiYearlyOutsideTemp="38.6";
lowYearlyOutsideTemp="-8.9";
humUnit="% ";
outsideHumidity="39";
hiHumidity="78";
hiHumidityAT=" 00:31";
lowHumidity="32";
lowHumidityAT="12:02";
hiMonthlyHumidity="94";
lowMonthlyHumidity="27";
hiYearlyHumidity="98";
lowYearlyHumidity="20";
outsideDewPt="12.2";
hiDewpoint="17.2";
hiDewpointAT="00:37";
lowDewpoint="10.6";
lowDewpointAT="05:44";
hiMonthlyDewpoint="22.8";
lowMonthlyDewpoint="10.0";
hiYearlyDewpoint="25.0";
lowYearlyDewpoint="-12.2";
windUnit="km/hr";
windSpeed="11.3";
wind10Avg="4.8";
hiWindSpeed="25.7";
hiWindSpeedAT="06:04";
hiMonthlyWindSpeed="53.1";
hiYearlyWindSpeed="61.2";
windDirection="EbS";
moires="96°";
windChill="27.3";
lowWindchill="20.6";
lowWindchillAT="00:32";
lowMonthlyWindchill="13.3";
lowYearlyWindchill="-9.4";
outsideHeatIndex="27.3";
hiHeatindex="31.7";
hiHeatindexAT="18:11";
hiMonthlyHeatindex="42.2";
hiYearlyHeatindex="45.0";
barUnit="hPa";
barometer="1016.7";
BarTrend="Rising Slowly";
hiBarometer="1019.3";
hiBarometerAT=" 09:07";
lowBarometer="1015.6";
lowBarometerAT=" 17:19";
lowMonthlyBarometer="1007.2";
hiMonthlyBarometer="1023.5";
lowYearlyBarometer="993.7";
hiYearlyBarometer="1037.6";
rainUnit="mm";
dailyRain="0.0";
stormRain="0.0";
monthlyRain="16.0";
totalRain="307.6";
rateUnit="mm/hr";
rainRate="0.0";
hiRainRate="0.0";
hiRainRateAT=" n/a";
hiMonthlyRainRate="36.6";
hiYearlyRainRate="1645.8";
solarUnit="W/m²";
solarRad="n/a";
hiSolarRad="0";
hiSolarRadAT="n/a";
hiMonthlySolarRad="0";
hiYearlySolarRad="0";
uvUnit="index";
uv="0.0";
hiUV="0.0";
hiUVAT="n/a";
hiMonthlyUV="0.0";
hiYearlyUV="0.0";
I try some tricks but I can't find the solution.
How can this data insert to mysql database auto every 10 minutes or 1 hour or ... etc?

How do I turn an array of strings into a select drop down menu in a Rails/JavaScript file?

I have a menu where I select a time slot and a JavaScript function is called.
$('#timeSlotSelect').on('change', function(event) {
alert($(this).val());
var time_slot = $(this).val();
var i = time_slot.indexOf(' ');
var dayFiltered = time_slot.substring(0, i);
$.ajax({url: "/activities/get_valid_date_range",
data: {day: dayFiltered},
type: 'POST'
});
})
It takes in the selected value and passes that into a controller method that prepares an array I'll need for the new select drop-down menu. My aim here is to populate this new select drop-down with a list of available dates for the selected time slot.
The controller method that gets called is:
def get_valid_date_range
respond_to do |format|
day = params[:day] # day param from javascript file
availableDates = valid_date_range(day) # logic that works out available dates
format.js { render :available_dates_select, :locals => { :dates => availableDates} }
end
end
The available_dates_select.js.erb file is:
$(function() {
alert("test")
$("div#jo").html("<%= escape_javascript dates.to_json %>")
});
Just to test, I converted the content of the array passed in from the controller to JSON, then I append it to a <div> in my view to see if it has the contents I expect.
View after JavaScript updates it:
["14th October 2014","21st October 2014","28th October 2014","4th November 2014","11th November 2014","18th November 2014","25th November 2014","2nd December 2014","9th December 2014","16th December 2014","23rd December 2014","30th December 2014","6th January 2015","13th January 2015","20th January 2015","27th January 2015","3rd February 2015","10th February 2015","17th February 2015","24th February 2015","3rd March 2015","10th March 2015","17th March 2015","24th March 2015","31st March 2015","7th April 2015","14th April 2015"]
What I need to do is take this array and turn it into a select drop-down. In the JavaScript file then add the select menu to the view instead of the raw array.
I tried a few snippets of code from here but none seem to work.
Would really appreciate an example to learn from.
Try
$("div#jo").html("<%= escape_javascript select_tag(:dates, options_for_select(dates)) %>")

Categories

Resources