Jump to content

maxxd

Gurus
  • Posts

    1,655
  • Joined

  • Last visited

  • Days Won

    51

Everything posted by maxxd

  1. 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?
  2. Not 'drop', 'dump'. Completely different thing in this context: https://www.php.net/manual/en/function.var-dump.php
  3. I don't recall WooCommerce having a wholesale/retail distinction out of the box; is this a plugin or am I remembering incorrectly?
  4. 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).
  5. 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.
  6. 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.
  7. 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.
  8. This genuinely delighted me - thank you. I've thought this same thing so many times at work...
  9. You have to wait until a document element is loaded in the DOM before you can use it or interact with it. Look into window.onload.
  10. cron.php is a standard file in WordPress installs, so if it's suddenly missing from the wp-includes directory then it got deliberately removed. I recommend re-installing WP and examining your logs for deletes or unusual/suspicious logins.
  11. <iframe width="420" height="315" src="<?php echo $row['url']; ?>"></iframe> This is a basic example - there are other, better ways to do this. For instance, the short echo tag is easier to read. The best idea is to use a template language like Twig, but that is a far more advanced operation. You'll also want to look into escaping your output as well.
  12. I''m pretty sure there was no information falling out - the person you were talking to was more than likely talking about at least two completely separate things. Flexbox has nothing at all to do with backgrounds; it's a two-dimensional layout system. Browser CSS support has gotten strong enough that CSS can do a lot of things these days (certainly much more than it could even just a short few years ago) and those things can affect pretty much every aspect of a page. Take some time to learn the basics. Even if you're a dedicated back-end developer working with a dedicated front-end developer, knowing how a page is structured and what can be done with that structure can help you determine how to collate and present to the front-end the data you pull from the back-end.
  13. If you're talking about the page background with the logo on the wall and the lamp; it's set up in the CSS using media queries. Inspect the element and resize the browser window; you'll see it's serving different images at different browser widths - this is a common practice in modern web development.
  14. I'm sure this isn't as easy as I'm making it out to be, but try to break it down to the basics. The command words in PHP don't change regardless the language spoken by the coder - the variable names and comments will change, but the command words don't. So don't worry about the specific command words while you're starting out. Learn what the constructs do, then learn what they're called. Think about is like this: a variable is learned knowledge that can change at any time if/when you learn something new a function is an action, more often than not done with and dependent on the knowledge you have from your variables at that point in time a control loop is the thought process about what to do and why to do it; it's heavily influenced by your variables and dictates the function that is performed a statement is kind of common knowledge or social agreement - it's an expected, repeatable outcome no matter the conditions around it This is massively simplified, but in my experience it's helped some people to step back and explore the basics before they start actually learning programming. After that, you can figure out when to use a for loop as opposed to a do or while loop - those are some of the command words you'll be dealing with. Disclaimer: Not gonna lie, I accidentally posted this halfway through typing it and then I had to edit it to finish it and I hope nobody was notified on the first post. I even though about deleting it entirely because english is my first (and only, unfortunately) language and most tech documentation I came across in my learning was in english so it was easier for me. Hopefully the above makes some sense, is contextually correct, and helps.
  15. You could also make life easier on yourself using crypto.randomUUID()
  16. It means $wp_query is null at the time the function is called. If I'm remembering correctly, this can happen if your function is called before the 'posts_selection' action is fired - if you're not in the loop.
  17. Just from the sample on Amazon it looks like the book defines the terms you'll need to know pretty quickly - function, variable, statement, control loops, etc. The thing to remember is that none of these are specific to PHP so if you can find a good general introduction to programming in your native language you should be able to get enough to start understanding the specific things PHP does with all the general constructs. I hope that makes sense.
  18. Also, 'Allowing users to register accounts' seems to be a very specific thing that can vary a lot depending on the system/setup you're using. What's the name of the book you're using?
  19. I believe Pusher is your best bet if you're determined not to use websockets, although there may be a better solution these days.
  20. So, it looks like there are a lot of things going on here. First off, when you create an array you want to wrap the string values in quotes. This alone should be throwing an error about undefined constants. Now, inside your function you refer to the array you created outside the function. This should also be throwing an error about an undefined variable - the $array1 array doesn't exist inside that function. Read up on variable scope - it's an important concept. What you need to do is see what exactly the $field_ids parameter contains and what the values correspond to. You can do that by adding this right after the opening bracket in the function signature: die("<pre>".var_export($field_ids, true)."</pre>"); Then remove the appropriate value from the $field_ids array (not $array1 - that doesn't exist in this function, remember) before you return it. Most importantly, on your development machine open the file 'wp-config.php'. Look for a line that reads `define( 'WP_DEBUG', false );` (in the sample file it's on line 82) and change it to read `define( 'WP_DEBUG', true );`. This will let you know when errors like the above happen.
  21. I'm pretty sure I don't understand the issue you're having, but right off the top I see this. This is your function definition: function getItemsForQuote($itemType, $currency, $qty = null, $startDate = null, $endDate = null, $itemId = null, $notes = null) and this is what you're calling: getItemsForQuote($item['itemType'], $item['quoteCurrency'], $item['quantity'], $item['itemId']); You're passing the itemId as the startDate parameter.
  22. I initially went with concatenation because best practices in HTML recommend using double quotes for attribute values so far as I recall. All that having been said, obviously this becomes much easier using a template framework like Twig or Blade. <option value="{{ $myrow['cats'] }}">{{ $myrow['cats'] }}</option> Not only that, both escape output by default.
  23. Groovy - I'm genuinely glad that works and helped you out. Now for bonus points, can you explain why it works?
  24. This is one of the major problems with echoing html from within php - your quotation marks are getting lost/confused. If you have to do this, remember using single quotes is perfectly appropriate for an echo statement in php even though it won't interpolate variables. In your case, this is fine as you're using concatenation. Try this: echo '<option value="'.$myrow['cats'].'">'.$myrow['cats'].'</option>'; This way it's easier to see that there are quotes around the option value so you know that spaces in the value won't break the entire thing (which is what's happening to you now). It's also a best practice in html to use double quotes for attribute values, so that's cool too. I made the quotes around the array indexes single quotes; I'm not entirely sure that's best practice for php but it's what I've seen most often and what I personally prefer, so...
  25. If you're specifically looking for a title attribute and not the post body itself, I'd look at adding a maxlength attribute to your input field. You'll want to validate and, if necessary, truncate the text on the server side as suggested by Barand (or just reject the input wholesale) because there are ways around the browser, but it's a start. Admittedly from what I see the title doesn't seem to be the issue in the screencap you posted, so I'll say if I'm misunderstanding what you're calling things and you're referring to what is typically the post body you'll probably want the WP-specific the_excerpt function.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.