-
Posts
1,698 -
Joined
-
Last visited
-
Days Won
53
Everything posted by maxxd
-
I feel like something else is happening - this code works for me: <script src="https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js"></script> <script> function setCookie(){ Cookies.set('testing2', JSON.stringify([{ testing1: 'hi there', testing2: 'whaddup?!?', testing3: 'how you doing?', }]), { expires: 3650 }); } var json_string = Cookies.get('testing2'); console.log(json_string); if(typeof json_string == 'undefined'){ setCookie(); json_string = Cookies.get('testing2'); } console.log(json_string); </script> First time I visit the page, i get 'undefined' followed by the JSON string. Subsequent visits give me the JSON string both times. The only real difference here is that I'm setting json_string from the cookie after I set it where you're hard-coding the value. But even then, you shouldn't be seeing the 'set new cookie' console log because after the first page load the cookie would be set. What does your entire script look like? Are you getting any errors?
-
Your last post isn't the same code as your first. It's the code I told you to run - the parenthesis have nothing to do with it, it's using typeof result as a comparator, not in window.
-
Have you tried swapping this: !(json_str in window) with this: typeof json_str == "undefined"
-
When dealing with cookies in Javascript, I usually use this library. In my experience it's just easier and less clunky.
-
Again - you're already in php mode, so using the opening and closing php tags is redundant and will throw an error. Change this line: header('link: < https://example.com<?php echo ($_SERVER['REQUEST_URI']); ?>>; rel="canonical"'); to this: header('link: <https://example.com/'.$_SERVER['REQUEST_URI'].'>; rel="canonical"'); and see what that gives you.
-
You're already in php, so you don't need the `<?php echo` and `?>` around the $_SERVER['REQUEST_URI']. You will, however, have to concatenate as you're using single quotes for that header string and single quotes won't interpolate php code. I'm not overly familiar with the `link` header so I can't say for certain, but I wouldn't be surprised if there were additional syntax errors on that line.
-
Need some help with customizing this PHP code
maxxd replied to jacquesdegatineau's topic in PHP Coding Help
Is there a reason you're not just using the shortcode multiple times with different video IDs? The function just returns a number; you can add formatted text around the numbers. -
I think I misinterpreted the original post. I read it as 'favorite of three flavors', not 'favorite three flavors'. Given that, I wouldn't recommend using an enum datatype. Personally, I'd probably go with a table to keep the flavors and another table to keep the votes. Count and group on select and everything's good to go. It's honestly just an over-engineered version of kicken's suggestion, but I have a tendency to over-engineer at the outset...
-
To make it even simpler (maybe), you could actually have a single column in your table - use an enum with the three flavors as the values. Each row represents a vote - then you can count and group by value. Not sure it's worth doing this over kicken's suggestion, just another way to look at it.
-
It's been a while since I've dealt with WooCommerce and even in my current job my interaction with WP core has been limited so ymmv, but given you're talking about WordPress plugins I assume the global $post variable is available. If I remember correctly (and a quick SO search didn't lead my brain astray) you should be able to add `$order = new WC_Order($post->id);` before the code requinix suggested if you get an error with just that code alone. WordPress relies heavily on global variables and this unfortunately makes debugging difficult at times...
-
Whether it's padding or margin in this case doesn't really matter - the question could still be valid and of use to others. If you could explain a bit more fully what it is you're after and what you've tried we can all work to come to a solution that works regardless the target attribute.
-
How to manipulate multi-dimension array in PHP?
maxxd replied to soyaslim's topic in PHP Coding Help
That's what I get for responding grumpy and insufficiently caffeinated. I missed the whole part about skipping entries based on ID. -
You've hard-coded a customer id of 1 into your query. Change that to be a prepared statement placeholder.
-
How to manipulate multi-dimension array in PHP?
maxxd replied to soyaslim's topic in PHP Coding Help
This is exactly the same as the question barand solved for you here less than 24 hours ago. Apply what you're being told. -
What does your App\Models\Admin class look like?
-
The only margin of zero in your code is the top and bottom margins, and they'll be zero at any browser size. I'm not gonna lie, I'm not completely sure I understand the question you're asking but it sounds like you may be looking for CSS clamp().
-
PHP isn't targeting guest customers in Woocommerce
maxxd replied to martini0's topic in PHP Coding Help
This may help: https://wholesalesuiteplugin.com/kb/how-to-hide-prices-for-not-logged-in-customers-guests/ -
PHP isn't targeting guest customers in Woocommerce
maxxd replied to martini0's topic in PHP Coding Help
Apparently I was incorrect; I thought the third parameter of get_user_meta was a default value. It's actually telling the function what type of value to return - an array if false, a value if true So it sounds like all your registered users are set to have a meta value of wholesale_customer = true. How is the system creating the distinction between wholesale and non-wholesale user accounts? -
Not 'drop', 'dump'. Completely different thing in this context: https://www.php.net/manual/en/function.var-dump.php
-
PHP isn't targeting guest customers in Woocommerce
maxxd replied to martini0's topic in PHP Coding Help
I don't recall WooCommerce having a wholesale/retail distinction out of the box; is this a plugin or am I remembering incorrectly? -
A controller isn't specific to PHP - it's part of the MVC design pattern. (I've skimmed the article and it looked like it'll explain the concept and give you a place to start reading).
-
PHP isn't targeting guest customers in Woocommerce
maxxd replied to martini0's topic in PHP Coding Help
Unless $is_wholesale is true for customers that aren't wholesale customers, the logic still seems backwards to me. Though admittedly, it's been a long week and I may be mis-reading it. -
PHP isn't targeting guest customers in Woocommerce
maxxd replied to martini0's topic in PHP Coding Help
wholesale_user might be a valid user type, but your code is checking for wholesale_customer and returning true if it's not found. In addition, your conditional is backwards - the comment says flat_rate:7 and flat_rate:10 are to be removed for non wholesale customers, but shipping_rates_ids is being populated with those values when $is_wholesale is true. -
Insert Randomly Generated name and surname into sqlite DB.
maxxd replied to nickRSA's topic in PHP Coding Help
You've also got a quote issue in your actual query string. Notice the first %s is surrounded by double quotes and a different color than the rest? Change those quotes to single quotes. And not to continue beating a dead horse, but I too hate what you're doing. This is how WordPress does 'prepared statements' (or at least it was last time I looked a couple years ago). Don't be like WordPress.