B
B
blackster682020-02-14 17:10:43
JavaScript
blackster68, 2020-02-14 17:10:43

Category nesting in Woocommerce Wordpress?

There is an online store on Wordpress + Woocommerce. Now the CNC
structure for product categories is as follows : https://site.ru/catalog/parent1/parent2/category/ the address must contain only the /catalog/ nesting and the category address, regardless of the nesting level at which this category is located. How best to implement? M.b. is there some lightweight plugin?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dollar, 2019-06-09
@dollar

To understand what's going on, you just need to look . For example, like this:

Example
var q = (function(x,foo = () => x) {
  console.log('a)',x,y,foo()); //2 undefined 2
  var x;
  console.log('b)',x,y,foo()); //2 undefined 2
  var y = x;
  console.log('c)',x,y,foo()); //2 2 2
  x =3;
  console.log('d)',x,y,foo()); //3 2 2
  return [x,y,foo()];
})(2)
console.log(q) // [3,2,2]
More detailed example
var q = (console.log('init q',typeof x), //init q undefined
  function(x,foo = (console.log('init foo',x),() => x)) { //init foo 2
    console.log('a)',x,y,foo()); //2 undefined 2
    var x;
    console.log('b)',x,y,foo()); //2 undefined 2
    var y = x;
    console.log('c)',x,y,foo()); //2 2 2
    x =3;
    console.log('d)',x,y,foo()); //3 2 2
    return [x,y,foo()];
  }
)(2)
console.log(q) // [3,2,2]

In general, there, at the time of initialization of the foo function, the scope of the anonymous function is visible. But the anonymous function actually has two of these local scopes. The first contains the function parameters, and the second contains the function's local variables. And this var x sits in the second and overlaps the first scope. That is, foo does not see var x, but only sees the x that is in the parameters, because foo itself also sits in the first scope. Hope it's available.

W
William Thorn, 2019-06-09
@xydope

It's all about declaring variables.
var declares a variable X within the entire scope of the function, while the function refers to X within the scope of the block of curly braces {}.
let-const-var;
scopes ;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question