Forum Replies Created
- AuthorPosts
-
January 31, 2023 at 7:49 am in reply to: Magento 2 different prices on page product and search results #9904
abctest483MemberI figured it out,it seems that in my case , when I updated a specific third party module, there was some sort of update on the table catalog_product_index_price_tmp.
I deleted the table and created it manually, bad mistake, this table is used for updating the catalog product index (not sure if others), it stores the information on that table and then copies its values to the _replica one, this table is always emptied when reindexing the price.
Solution was to delele the table
DROP TABLE `catalog_product_index_price_tmp`;And then run the setup:upgrade , this table is created by magentos db_schema.xml in this file vendor/magento/module-catalog/etc/db_schema.xml
Hope this helps others
January 23, 2023 at 4:04 am in reply to: How can I paginate WP_Query results when there's an offset? #9417
abctest483MemberI know this might not be the solution for this but instead of using offset for highlighting a different container for a post I decided to break down the query with $count and add different wrappers instead due to the difficulty of offset pagination. Here’s what I ended up using:
<?php $args = array( 'posts_per_page' => 13, 'post_type' => 'post', 'paged' => get_query_var( 'paged' ), ); $wp_query = new WP_Query( $args ); $count = 0; while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <?php if($count == 0): ?><!-- first highlighted post we show with categories on side --> <div class="mb-4 flex flex-col flex-col-reverse gap-4 md:mb-10 md:flex-row md:gap-10 "> <aside class="flex flex-col items-baseline gap-2 no-gap:mt-4 md:max-w-[200px] md:gap-4 no-gap:md:mt-0 no-gap:md:mr-10"> <h2 class="flex-none font-denim-semibold text-sm xs:text-lg no-gap:mb-2 no-gap:md:mb-4">Categories</h2> <?php $terms = get_terms( 'category' ); echo '<ul class="flex flex-wrap gap-2 no-gap:-m-1">'; echo '<li class="no-gap:m-1"><button class="flex justify-center items-center gap-2 rounded-xl select-none min-w-fit px-3 py-1 xs:px-3.5 xs:py-2 bg-brand-black ring-1 ring-inset ring-brand-black focus-visible:outline focus-visible:outline-4 focus-visible:outline-offset-0 focus-visible:outline-brand-black/20 text-white text-xs xs:text-sm rounded-xl" tabindex="0" type="button"><span class="no-gap:ml-2 no-gap:first:ml-0">All</span></button></li>'; foreach ( $terms as $term ) { $class = ( is_category( $term->name ) ) ? 'active' : ''; // assign this class if we're on the same category page as $term->name if($class == 'active'): echo '<li class="no-gap:m-1"><a href="' . get_term_link( $term ) . '" class="' . $class . '"><button class="flex justify-center items-center gap-2 rounded-xl select-none min-w-fit px-3 py-1 xs:px-3.5 xs:py-2 bg-brand-black ring-1 ring-inset ring-brand-black focus-visible:outline focus-visible:outline-4 focus-visible:outline-offset-0 focus-visible:outline-brand-black/20 text-white text-xs xs:text-sm rounded-xl" tabindex="0" type="button"><span class="no-gap:ml-2 no-gap:first:ml-0">' . $term->name . '</span></button></a></li>'; else: echo '<li class="no-gap:m-1"><a href="' . get_term_link( $term ) . '" class="' . $class . '"><button class="flex justify-center items-center gap-2 rounded-xl select-none min-w-fit px-3 py-1 xs:px-3.5 xs:py-2 bg-transparent hover:bg-brand-black/10 active:bg-brand-black ring-1 ring-inset ring-brand-black focus-visible:outline focus-visible:outline-4 focus-visible:outline-offset-0 focus-visible:outline-brand-black/20 text-brand-black active:text-white text-xs xs:text-sm rounded-xl" tabindex="0" type="button"><span class="no-gap:ml-2 no-gap:first:ml-0">' . $term->name . '</span></button></a></li>'; endif; } echo '</ul>'; ?> </aside> <a class="w-full " href="<?php the_permalink(); ?>"> <article class="group isolate relative w-full rounded-3xl bg-brand-black shadow-lg transition overflow-hidden duration-300 overflow-border-transition will-change-contents hover:cursor-pointer hover:shadow-xl hover:scale-[1.025] active:scale-[0.975] active:shadow-md active:transform-none active:outline-none focus:outline-4 focus:outline-brand-blue focus:outline-offset-0 focus:outline"> <div class="mx-auto flex w-60 flex-col text-center py-28 md:p-16 lg:p-28 transition duration-300 group-hover:scale-[1.025] md:w-4/5 lg:w-3/4"> <span class="z-10 text-white opacity-70">4 min read</span> <h2 class="z-10 text-3xl text-white md:text-4xl "><span class="font-reckless-neue"><?php the_title(); ?></span></h2> </div> <div class="absolute right-1/2 top-1/2 -translate-y-1/2 translate-x-1/2 select-none transition duration-300 group-hover:scale-[1.05]"> <object aria-label="Tuum blue thick wheel" class="pointer-events-none h-[1000px] min-w-[1000px] max-w-[1000px] animate-spin-slow md:h-[1250px] md:min-w-[1250px] md:max-w-[1250px] lg:h-[1500px] lg:min-w-[1500px] lg:max-w-[1500px]" data="<?php if(get_field('wheel')): ?><?php the_field('wheel'); ?><?php else: ?><?php bloginfo('template_url'); ?>/assets/img/about-us-bg.svg<?php endif; ?>" tabindex="-1" type="image/svg+xml"></object> </div> </article> </a> </div><!-- first loop --> <?php elseif($count == 1): ?><!-- second post we open up with new wrapper and section --> <section> <ul class="grid gap-4 md:gap-x-8 md:gap-y-10 grid-cols-2 md:grid-cols-3 lg:grid-cols-4 pb-10 border-b-2 border-solid border-brand-beige-600"> <?php get_template_part( 'templates/partials/component','postSmall'); ?> <?php else: ?><!-- from there we continue as normal --> <?php get_template_part( 'templates/partials/component','postSmall'); ?> <?php endif; ?> <?php $count++; endwhile; ?> <?php wp_reset_postdata(); ?> </ul><!-- close the post small boxes list --> <div class="navigation-wrap flex justify-center items-center gap-2 rounded-xl select-none min-w-fit tracking-normal px-7 py-4 bg-transparent ring-transparent text-brand-black text-xl rounded-xl font-denim-semibold w-full mt-4 justify-center col-span-2 md:col-span-3 lg:col-span-4"> <?php echo paginate_links(array( 'base' => get_pagenum_link(1) . '%_%', 'format' => 'page/%#%', 'prev_text' => '', 'next_text' => '' )); ?> </div> </section><!-- close the small posts section wrap -->Using Tailwind css but query tested and working to show 1st post highlighted aside with category filter and other posts in a 4post grid. Hope this helps someone struggling with this since I spent a lot of time with the offset solution and decided to still solve with a single loop for simplicity
abctest483MemberIt will work 🙂
$(‘.ic-star[data-rate="1"]’).addClass(‘rated’);
abctest483MemberAs it is not clear what OS you are on these are my 2 Windows cents.
If you are using XAMPP you need to manually create thelogsfolder underC:\xampp\php. Not your fault, ApacheFriends ommitted this.To read and follow this file do.
Get-Content c:\xampp\php\logs\php_error_log -WaitTo do this in VSCode create a task in
.vscode\tasks.json{   // See https://go.microsoft.com/fwlink/?LinkId=733558   // for the documentation about the tasks.json format   "version": "2.0.0",   "tasks": [     {       "label": "Monitor php errors",       "type": "shell",       "command": "Get-Content -Wait c:\\xampp\\php\\logs\\php_error_log",       "runOptions": {         "runOn": "folderOpen"       }     }   ]and have it run on folder load.
December 1, 2022 at 7:24 am in reply to: How To Include CSS and jQuery in my WordPress plugin? #10000
abctest483MemberFor css
wp_register_style('style-css',plugin_dir_url(__FILE__).'css/style.css');for js
wp_register_script('script-js', plugin_dir_url(__FILE__).'js/script.js',array(), '1.0.0', true);you can use the css by enqueue them in any page like
wp_enqueue_style('style-css');you can use the js by enqueue them in any page like
wp_enqueue_script('script-js');November 9, 2022 at 8:49 am in reply to: #1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’ #10686
abctest483MemberUse the sed command to replace text in files directly
Linux OS
sed -i 's/utf8mb4_unicode_520_ci/utf8mb4_general_ci/g' YOUR_SQL_FILE.sqlMac OS
sed -i '' s/utf8mb4_unicode_520_ci/utf8mb4_general_ci/g' YOUR_SQL_FILE.sqlThe help of this command i have fixed issue ERROR 1273 (HY000) at line 51: Unknown collation: ‘utf8mb4_unicode_520_ci’
November 7, 2022 at 3:56 am in reply to: #1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’ #10684
abctest483MemberAfter a little investigation, I found that the MySQL server running on the destination is an older version than the source. So we got that the destination server doesn’t contain the required database collation.
Then we do a little tweak in the backup file to resolve this. Edit the database backup file(
your_sql_file.sql) in a text editor and replaceutf8mb4_unicode_520_ciwithutf8mb4_general_ciandCHARSET=utf8mb4withCHARSET=utf8.I hope this solution might help you.
abctest483MemberGo with native solution if possible, it’s always the best solution as it comes natively from browser (using
embedoriframe), or you can use this tiny lib to support you on that: https://pdfobject.comMost people recommend using PDF.JS which is famous. It has been working fine until I need to work with ShadowDOM. Some pages are in blank (white color), some in black color without any reason. Impossible for me to get to know what’s happening, and it’s in production :).
abctest483MemberJust to show you a working example, you can use
prefers-color-schemefor automatic toggling and also create a dark-mode and light-mode classes, for manual toggling.document.getElementById("theme").addEventListener("click", function () { if (window.matchMedia("(prefers-color-scheme: dark)").matches) document.body.classList.toggle("light-mode"); else document.body.classList.toggle("dark-mode"); });@media (prefers-color-scheme: dark) { :root { --color-primary: #0a0a0a; --color-secondary: #339eff; } } @media (prefers-color-scheme: light) { :root { --color-primary: #ffffff; --color-secondary: #ff7e33; } } .light-mode { --color-primary: #ffffff; --color-secondary: #ff7e33; } .dark-mode { --color-primary: #0a0a0a; --color-secondary: #339eff; } body { background-color: var(--color-primary); color: var(--color-secondary); }<!DOCTYPE html> <html lang="pt-BR" xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br"> <head> <meta name="color-scheme" content="dark light" /> <meta name="theme-color" media="(prefers-color-scheme: dark)" /> <meta name="theme-color" media="(prefers-color-scheme: light)" /> </head> <body> This is a test <button id="theme">Change theme</button> </body> </html>You can change it to your needs, but this is according to web.dev. Remember to set the prefers-color-scheme colors, and then change it automatically or by a manual toggle, using the .light-mode and .dark-mode classes.
October 18, 2022 at 3:31 am in reply to: Which hook to use to save order meta data before email notifications are send in WooCommerce #11095
abctest483MemberYou can use the
woocommerce_checkout_create_orderor thewoocommerce_checkout_update_order_metaaction hook.So you would get:
/** * Action hook to adjust order before save. * * @since 3.0.0 */ function action_woocommerce_checkout_create_order( $order, $data ) { // Some value $my_custom_address = 'My custom address'; // Update meta data $order->update_meta_data( '_billing_address_1', $my_custom_address ); $order->update_meta_data( '_shipping_address_1', $my_custom_address ); } add_action( 'woocommerce_checkout_create_order', 'action_woocommerce_checkout_create_order', 10, 2 );OR
/** * Action hook fired after an order is created used to add custom meta to the order. * * @since 3.0.0 */ function action_woocommerce_checkout_update_order_meta( $order_id, $data ) { // Get an instance of the WC_Order object $order = wc_get_order( $order_id ); // Is a WC_Order if ( is_a( $order, 'WC_Order' ) ) { // Some value $my_custom_address = 'My custom address'; // Update meta data $order->update_meta_data( '_billing_address_1', $my_custom_address ); $order->update_meta_data( '_shipping_address_1', $my_custom_address ); // Save $order->save(); } } add_action( 'woocommerce_checkout_update_order_meta', 'action_woocommerce_checkout_update_order_meta', 10, 2 );
abctest483MemberIn your CSS, white-space can do the job
possible values:
white-space: nowrap white-space: pre white-space: pre-wrap white-space: pre-line white-space: break-spaces white-space: normal
abctest483MemberOpen ssh.
Type the following code:
nano /etc/httpd/conf.d/phpMyAdmin.confand replace from
<Directory /usr/share/phpMyAdmin/>to</Directory>with this code:
<Directory /usr/share/phpMyAdmin/> AddDefaultCharset UTF-8 <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> #Require ip 127.0.0.1 #Require ip ::1 Require all granted </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory>Enjoy 🙂
abctest483MemberI answered this question already somewhere else, however, I did an evaluation between multiple solutions. Also if you are planning for commercial use, these might be helpful:
free solutions
- iframe: Just use an iframe, however, this is not what most people search here.
- [Google Docs Preview] Google docs has a preview (See other answer here)
- Pdf.js is the open source solution without external dependencies
- Adobe offers a ‘free’ PDF Embed API – recommended approach if you are okay with a cloud based solution.
Commercial Providers
- Pdf.js Express is commercialized extension to Pdf.js (worst performing product, not expensive)
- PSPDFKit – Provder from Austria with rather good business support (moderate pricing, good product)
- Foxit – Chinese company providing a PDF web solton as well. (cheapest commercial offer)
- PDFTron – US-based competitor to PSDPDFkit ( more costly but also mot advanced)
Hope this helps. I might publish more detailed information in a blogpost, if this is helping people (let me know in comments).
September 2, 2022 at 10:17 am in reply to: What's the cause of the error 'getaddrinfo EAI_AGAIN'? #9274
abctest483MemberFor those who perform thousand or millions of requests per day, and need a solution to this issue:
It’s quite normal to get
getaddrinfo EAI_AGAINerrors when performing a lot of requests on your server. Node.js itself doesn’t perform any DNS caching, it delegates everything DNS related to the OS.You need to have in mind that every http/https request performs a DNS lookup, this can become quite expensive, to avoid this bottleneck and
getaddrinfoerrors, you can implement a DNS cache.http.request(and https) accepts alookupproperty which defaults todns.lookup()http.get('http://example.com', { lookup: yourLookupImplementation }, response => { // do something here with response });I strongly recommend to use an already tested module, instead of writing a DNS cache yourself, since you’ll have to handle TTL correctly, among other things to avoid hard to track bugs.
I personally use
cacheable-lookupwhich is the one thatgotuses (seednsCacheoption).You can use it on specific requests
const http = require('http'); const CacheableLookup = require('cacheable-lookup'); const cacheable = new CacheableLookup(); http.get('http://example.com', {lookup: cacheable.lookup}, response => { // Handle the response here });or globally
const http = require('http'); const https = require('https'); const CacheableLookup = require('cacheable-lookup'); const cacheable = new CacheableLookup(); cacheable.install(http.globalAgent); cacheable.install(https.globalAgent);NOTE: have in mind that if a request is not performed through Node.js
http/httpsmodule, using.installon the global agent won’t have any effect on said request, for example requests made usingundici
abctest483MemberI know this is a old thread but i’ve stumbled here while i was searching for the answer and just wanted to share my solution with you guys that also have the same problem. This is how i’m getting shop domain.
let shopDomain = new URL(window.location).searchParams.get("shop"); - AuthorPosts