-
Posts
15,227 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Need some help with customizing this PHP code
requinix replied to jacquesdegatineau's topic in PHP Coding Help
First thing you have to consider is that you don't want to hit the YouTube API 25 times every time you want these numbers. Wouldn't it be nice if you could get all of them at once? And you can: take that URL you have and add all the video IDs separated by commas. And you don't need a "id" parameter if you know exactly which videos you want. Then, since there will be multiple videos in the results, you'll need to total up all the views across all of them. That means a loop. $views = 0; foreach ($jsonData->items as $item) { $views += $item->statistics->viewCount; } -
If you're specifying a canonical URL then using the REQUEST_URI is almost definitely wrong. Because that will result in your site claiming that the canonical URL is whatever I put into the address bar of my browser. You need to decide what that URL is supposed to be, with correct values (eg, slugs) and without any extraneous query string parameters, and provide that for the Link.
-
Need some help with customizing this PHP code
requinix replied to jacquesdegatineau's topic in PHP Coding Help
Do you actually need these "shortcode" things for your site? Or do you just need to embed this number in a page somewhere? And how many videos are you talking about? -
Really? https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API https://developer.mozilla.org/en-US/docs/Web/API/Response
-
If you're making your own grid layout then stop doing that and use the existing grid layout instead. https://developer.mozilla.org/en-US/docs/Web/CSS/grid
-
As long as your preference is not to add columns for the different flavors.
-
Method called from another method in the same class not working
requinix replied to drezzia's topic in Javascript Help
To be a little more clear about what I think eaglehopes is saying: The "this" in your code here let el = $(this); is not going to be the same "this" that was your Store object. You already know that: it will be the element that was clicked. However, later you then try to do this.show_price(); "this" is going to be the exact same one as it before. If you want to remember which Store object you're running with, assign "this" to a variable outside the click handler (where it will be the Store object) then reference that variable inside it. -
If you plug your PHPF email into https://haveibeenpwned.com you'll see it's listed in one breach: ours, that kicken linked to. I also just did a quick audit of some stuff and didn't see anything unusual.
-
Find an API for the CRM and write PHP code to use it. You haven't given enough information to be able to answer better than that...
-
PHP cannot create popups. If you moved from one PHP website to another PHP website then I suggest you see if you can copy what you had before.
-
receipt_services_meta() is intended to display some HTML table of data. If you just want one value out of it, without a table, then you can't actually use the function. But you can look at the function and mirror how parts of it work. Specifically, the bits that involve the $service_time. $service_time is defined as $service_time = get_post_meta( $order_id, '_wfs_service_time', true ); so the first question is: how do you get $order_id? That came from $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id(); so next is: how do you get $order? Because that was provided to the receipt_services_meta() function by something else. If you're lucky, the $order from the first plugin may be the same as the $this->object from the second plugin. I'm skeptical, but without knowing more you might as well try it out. $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->object->id : $this->object->get_id(); $service_time = get_post_meta( $order_id, '_wfs_service_time', true );
-
fetch returns a Promise immediately. That does not mean the Promise has been resolved yet.
-
At the top-level you do not use awaits, and instead the Javascript runtime will handle them. As in, if it finds a dangling Promise somewhere then it will go ahead and let it run to completion. That's why you can call fetch().then().catch() without having to await anything yourself. You also do not need to use await inside the .then(). It's okay to return a Promise, which is what .json() will return. That Promise it returns then gets "unwrapped" before the next .then kicks in. In other words, why are you adding async/await in the first place? Is there a reason, or are you just trying to learn more about it?
-
Are you sure that URL is returning what you expect? What do you see if you console.log the whole data object?
-
Re: july 2021 version update
requinix replied to mac_gyver's topic in PHPFreaks.com Website Feedback
Done. -
Re: july 2021 version update
requinix replied to mac_gyver's topic in PHPFreaks.com Website Feedback
Ahhh, I forgot about the template edit... -
What have you tried so far?
-
Maybe. Maybe not. Really hard to tell since we don't know how SendMail works. Try it and find out.
-
How to manipulate multi-dimension array in PHP?
requinix replied to soyaslim's topic in PHP Coding Help
Start with a blank array where you'll hold all the previous rolanIDs that you have "seen" associated with other suppliers. Then loop through your $test array. For each supplier, look at each of their rolanIDs. If the value exists in the "seen" array then unset it in the supplier's array. If not then add it to the "seen" array. When you've looked through a supplier's rolanIDs, check if that array is now empty (because you removed everything in it). If so, remove the entire supplier from your $test array. Questions? Try writing code for that. If you have problems, post the code you've written so far and tell us about what's going wrong. -
Looks good so far.
-
Are you trying to show prospects with some of the deal information? Or deals with some of the prospect information? The latter is easier: you SELECT the fields you want FROM the deals table, then JOIN in the prospects table ON the two tables matching their prospect IDs (and also add the fields you want from that to the SELECT list, of course). The fact that the same prospect could show up multiple times for multiple deals isn't important. The former is a bit trickier because you should think a little harder about precisely what it is you want to do. Show a prospect and then list the associated deals underneath? Somehow summarize all the matching deals? Your example seems to suggest that you want to focus on the deal information, then show alongside it the information about its prospect.
-
Dump the value of __DIR__ so you can see what it ends with. You can assume that's mostly always going to be the case. Then consider whether there are possible exceptions to that. Then realize that having doubled-up slashes doesn't cause any problems.
-
As long as each one has the $ then it's a variable, and if undefined PHP will just treat it as null (and 0). The name-to-string thing applies only to constants, as in code like const PREVBAL = 1; const LATECHG = 2; const SECDEP = 3; const DAMGE = 4; // typo const COURTCOST = 5; const NSF = 6; $due = PREVBAL + LATECHG + SECDEP + DAMAGE + COURTCOST + NSF; and that behavior has actually been removed since PHP 8.