If you need to remove ALL WooCommerce data, including products, order history, reports, etc., you need to be able to modify the site’s wp-config.php file to set a constant as true.
To do that you need to add the following code snippet to your site’s wp-config.php file.
define('WC_REMOVE_ALL_DATA', true);
Please make sure add the above snippet on its own line above the /* That’s all, stop editing! Happy blogging. */ line.
// Make a request for a user with a given IDaxios.get('/user?ID=12345').then(function(response){console.log(response);}).catch(function(error){console.log(error);});// Optionally the request above could also be done asaxios.get('/user',{params:{ID:12345}}).then(function(response){console.log(response);}).catch(function(error){console.log(error);});
functiongetUserAccount(){returnaxios.get('/user/12345');}functiongetUserPermissions(){returnaxios.get('/user/12345/permissions');}axios.all([getUserAccount(),getUserPermissions()]).then(axios.spread(function(acct,perms){// Both requests are now complete}));
POST request config
// Send a POST requestaxios({method:'post',url:'/user/12345',data:{firstName:'Fred',lastName:'Flintstone'}});
GET request config
// GET request for remote imageaxios({method:'get',url:'http://bit.ly/2mTM3nY',responseType:'stream'}).then(function(response){response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))});
var greeting='Welcome to blog';
(function(){
console.log(greeting); //Output: Welcome to blog
})();
consider above code greeting variable should be global scope, it can access inside the function,
(function(){var greeting = 'Welcome to blog';
console.log(greeting); //Output: Welcome to blog
})();console.log(greeting); //Output:Reference-Error greeting not defined
The * wildcard simply works as a fallback. If a route fails to meet any other path, it then loads the path with the *. If there is no wildcard route and the route did not meet any other path, nothing is loaded.
Your custom props can be passed by putting your component in the Route slot (Employees example above).
Paths with parameters (:param) are passed to components via props: router.params.
Parameters like *param will capture the rest of segments. You can access them as router.params._ like other params.
A component loaded by <Route> receives a property with route details:
<!-- ./pages/About.svelte --><script>exportletrouter={};// Those contains useful information about current route statusrouter.path;// /testrouter.route;// Route Objectrouter.params;// /about/bill/123/kansas { who: 'bill', where: 'kansas' }</script>
Additional properties are passed to the mounted component, e.g.
<Routecomponent={Test}title="Some description" />
Also, you can pass an object:
<Routecomponent={Test}props={myProps} />
Route props are omitted, but all remaining ones are passed to Test.
Routes can also render any given markup when they're active, e.g.
Properties determine how routing will match and render routes:
Use the nofallback prop for telling <Router /> to disable the fallback mechanism by default
Any route using the fallback prop will catch unmatched routes or potential look-up errors
Use the exact prop to skip this route from render just in case it does not matches
A <Route /> without path will render only if <Router path="..." /> is active!
Note that all <Router /> paths MUST begin from the root as /sub and /sub/nested in the example.
Redirects
Sometimes you just want a route to send user to another place. You can use the redirect attribute for that.
A redirect should always be a string with a path. It uses the same pattern as path attribute. For a redirect to run, there must be a Route with the equivalent path.
If you need to meet a condition in order to run a route, you can use the condition attribute. Conditions can also be used with redirect for graceful route fallback.
A condition should be either boolean or a function returning boolean. There is no support for asynchronous conditions at the moment (so keep it simple).
Think of it as a simpler middleware. A condition will run before the route loads your component, so there is no wasteful component mounting, and no screen blinking the unwanted view.
Link Component
There is also an useful <Link> component that overrides <a> elements:
The difference between <Link> and <a> is that it uses pushState whenever possible, with fallback to <a> behavior. This means that when you use <Link>, svero can update the view based on your URL trigger, without reloading the entire page.
Given href values will be normalized (on-click) if they don't start with a slash, e.g. when location.pathname === '/foo' then #bar would become /foo#bar as result.
navigateTo()
In some cases you want to navigate to routes programatically instead of letting user click on links. For this scenario we have navigateto() which takes a route as parameter and navigates imediatelly to said route.
navigateTo() receives the same treatment as <Link>: It will always try to use pushState for better performance, fallbacking to a full page redirect if it isn't supported.
When you read lessons in this course, you can highlight a single line and save it to your notes. Simply highlight a single line with your mouse (or your finger on mobile) and then a popup will appear asking you to save it to your notes.
You will be able to find these notes in the challenge page by clicking on the Note icon on the top bar, next to the logo. Try it in the next page!
Popular notes will also be shown in yellow highlights which can be easily added to your notes with a single click. And you can also disable those popular highlights from the top right menu.
You can create a string in JavaScript by simply using the double quotes (") or single quotes (').
Here's an example:
"This is a string";'this is another string!'
There is no difference between using a double quote or a single quote. They are exactly the same. Both of these strings do not support interpolation (which means interpolating a variable inside of them). String interpolation will be covered in a future lesson.
Basic String properties
the .length property is used to return the length of the string.
Here's an example of getting the length of "Nice!":
"Nice!".length;//5
We will learn about variables later in this course, but assuming you have a variable called description, here's how you'd get its length:
description.length;
Basic String methods
Here are some common methods that you can call on strings:
.includes(searchString)
This method returns true when the searchString is included inside the parent string. For example:
This will return a new string that has all of its characters in upper case:
"hello".toUpperCase();// "HELLO";
.toLowerCase()
This will return a new string that has all of its characters in lower case:
"NICe".toLowerCase();// "nice";
Hint: Stuck? Feel free to use CodeToGo to search for common use cases
A note on tests & sample usage
On the left of the screen, you've got tests running your code. And in your editor, you will almost always have some sample usage code.
functionsum(a, b){return a + b;}//sample usagesum(1,3);
The sample usage code is meant to illustrate how your code will be used. However keep in mind that we will take the function that you wrote, and call it against several other possibilities to make sure that you've got the correct answer. Feel free to use console.log() for the parameters of the function to see what kind of tests we're running.
So even though the sample usage is sum(1, 3), we run more tests in the background with several values. We also often run it with edge case values such as sum(0, 0). All of this simulates a real Test Driven Development environment.
A note on console.log
When solving challenges feel free to add:
console.log(variable_or_expression)
to see its result in the console on the bottom left.
You can also use it to better understand theteststhat you're trying to pass.