Forum Replies Created

Viewing 15 replies - 1 through 15 (of 176 total)
  • Thread Starter codimex

    (@codimex)

    Oh! Thank you! I missed the “Syncing button” step. Thank you for your answer with illustrative images. You have my 5-star review.

    Thread Starter codimex

    (@codimex)

    After spending sooo many hours trying to figure it out, I finally came to a solution. Just in case someone faces the same issue. Disclaimer: I’m not an expert coder, and things probably could be done in a better way. Here it goes:

    1) In order to keep a frontend event submitter with four different fields (start_date_acf, start_time_acf, end_date_acf and end_time_acf), first you need to make sure that the ACF format of the fields are as follows:

      • start_date_acf: Y-m-d
      • start_time_acf: H:i:s (H:i also has proven to work for me)
      • end_date_acf: Y-m-d
      • end_time_acf: H:i:s (H:i also has proven to work for me)

      2) Then, I created two extra date/time fields (start_datetime_acf and end_datetime_acf ), both with format Y-m-d H:i:s, to merge the respecitve start date and time fields and end date and time fields.

      3) Then, I added this code to make Pie Calendar fetching start_datetime_acf and end_datetime_acf:

      add_filter("piecal_event_query_args", function ($args, $atts) {
      $args["meta_query"] = [
      "relation" => "AND",
      [
      "key" => "start_date_acf",
      "value" => "",
      "compare" => "!=",
      ],
      ];
      return $args;
      }, 10, 2);

      add_filter("piecal_start_date_meta_key", function ($key) {
      $key = "start_datetime_acf";
      return $key;
      });

      add_filter("piecal_end_date_meta_key", function ($key) {
      $key = "end_datetime_acf";
      return $key;
      });

      4) Then, I added this code, so that every time an event updates in the backend, the start_datetime_acf and end_datetime_acf fields are populated from start_date_acf, start_time_acf, end_date_acf and end_time_acf fields.

      function update_event_datetime( $post_id ) {
      if ( get_post_type($post_id) == 'product' ) {
      if ( wp_is_post_revision( $post_id ) )
      return;
      global $post;
      $start_datetime = (get_field('start_date_acf') . ' ' . get_field('start_time_acf'));
      update_post_meta($post_id, 'start_datetime_acf', $start_datetime);
      $end_datetime = (get_field('end_date_acf') . ' ' . get_field('end_time_acf'));
      update_post_meta($post_id, 'end_datetime_acf', $end_datetime);
      }
      }
      add_action( 'save_post', 'update_event_datetime', 10, 2 );

      5) Then, once the event is submitted from the frontend, just update it in the backend, and the two fields will be correctly merged and the calendar properly populated.

      Probably not the most optimal solution, but it’s tested and works. The issue is that if any of the events doesn’t have start_datetime_acf and end_datetime_acf field values populated, you’l get a fatal error (nothing too serious if you add those codes via Code Snippets plugin).

      Thank you, and feel free to close this ticket, unless you come up to a better idea.

      Thread Starter codimex

      (@codimex)

      Hi again. After burying CGPT with prompts asking for help, it’s stuck in a loop, suggesting once again the same code, which display all events piled up in the same cell (at the present moment, date and time). This is the shortest code I’ve got so far, based on your tutorial code, but unfortunately achieving the same wrong results. The first filter works fine, but the last two filters don’t pull the information from each post correctly:

      add_filter("piecal_event_query_args", function ($args, $atts) {
      $args["meta_query"] = [
      "relation" => "AND",
      [
      "key" => "start_date_acf",
      "value" => "",
      "compare" => "!=",
      ],
      ];
      return $args;
      }, 10, 2);

      add_filter("piecal_start_date_meta_key", function ($key) {
      global $post;
      $key = date("Y-m-d H:i:s", strtotime(get_field('start_date_acf', $post->ID) . ' ' . get_field('start_time_acf', $post->ID)));
      return $key;
      });

      add_filter("piecal_end_date_meta_key", function ($key) {
      global $post;
      $key = date("Y-m-d H:i:s", strtotime(get_field('end_date_acf', $post->ID) . ' ' . get_field('end_time_acf', $post->ID)));
      return $key;
      });

      I wish you can help me with finding directions towards the solution (considering I’m not an expert coder). Thank you!

      Thread Starter codimex

      (@codimex)

      Thank you for taking the time to help. I feel we are really close to the solution. This is the furthest I’ve gotten by mixing your answer with my intuition:

      add_filter("piecal_event_query_args", function ($args, $atts) {
      $args["meta_query"] = [
      "relation" => "AND",
      [
      "key" => "start_date_acf",
      "value" => "",
      "compare" => "!=",
      ],
      ];
      return $args;
      }, 10, 2);

      add_filter("piecal_event_start_datetime", function ($start_datetime, $post_id) {
      global $post;
      $start_date = get_field('start_date_acf', $post_id);
      $start_time = get_field('start_time_acf', $post_id);
      if ($start_date && $start_time) {
      $start_datetime = date("Y-m-d\TH:i:s", strtotime("$start_date $start_time"));
      }
      return $start_datetime;
      }, 10, 2);

      add_filter("piecal_event_end_datetime", function ($end_datetime, $post_id) {
      global $post;
      $end_date = get_field('end_date_acf', $post_id);
      $end_time = get_field('end_time_acf', $post_id);
      if ($end_date && $end_time) {
      $end_datetime = date("Y-m-d\TH:i:s", strtotime("$end_date $end_time"));
      }
      return $end_datetime;
      }, 10, 2);

      Now, all the events are shown in the actual current date and time, all piled in the same calendar cell (now’s date and time). If I refresh the page, the date and time of the event in the calendar also updates to match the actual date and time of this very moment. I’ve tried adding and removing global $post; but no success. And after a series of prompts to CGPT, it has come to an almost identical version of your own original code. Any new ideas? Why are the filters ignoring ACF field values? Is it due to a ACF date or time field format? Might this line Y-m-d\TH:i:s be the culprit?

      Thank you again for your willingness to help. I feel we’re really close to the solution!!!

      Thread Starter codimex

      (@codimex)

      Hi again. I’ve tried several approaches to solve this problem and I can’t figure out how to make it work. This is the most sense-making automation, so far:

      1. Custom event > order_completed
      2. Event data tracker > items > url > Contains > /en/
      3. Contact attributes > OPT_IN > Is identical > Yes
      4. Then, add the contact to “My Custom ENGLISH List”.

      But this doesn’t work.

      I thought today’s update 4.0.2 would fix the issue or at least cast light on it, since the changelog reads “Bug fixes related to incorrect handling of opt-in status of shop customers in checkout flow”, but at this point, I have NO IDEA of how to add customers to a language-specific list when they check the opt-in checkbox in the checkout.

      Any help? Anyone there? :/

      Thread Starter codimex

      (@codimex)

      Thank you, Eliot! Didn’t know about the “If (not) last” trick!

      Thread Starter codimex

      (@codimex)

      Thank you, Tony and Nicholas! Marking as resolved.

      Thread Starter codimex

      (@codimex)

      Hi again, Nicholas. Your settings were successful, and the consumed resources actually decreased. They are now below the server usage limit. BUT for some reason, I got penalized again by my server host. It’s something I’m discussing with them at the moment.

      I then reverted your settings to the default ones and tried a new backup. Please, see this attached image. The peak on the left is your suggested settings. The peak on the right is after reverting them to default. The cyan lines show the limit was reached, which doesn’t make sense to me in the case of the left peak.

      I just have one more question, before marking this as resolved, since your answer works: could I migrate a website by uploading the files using your settings to another domain, as I usually do with the default settings? Will your restoring system automatically detect the difference in PDO, PCLzip, etc.?

      Thank you!!!

      Thread Starter codimex

      (@codimex)

      Hi, thanks for your reply! Of course, I know you’re not in control of I/O usage in my server (“nobody” is), but the screenshot I attached shows a high peak in the moment I hit on the “Backup now” button. Let’s see if your settings provided can mitigate it a little. ??

      Please keep this thread open a couple of days more until I come back with my feedback after applying your settings. In the meantime, thank you again!!!

      Thread Starter codimex

      (@codimex)

      Hi again! This was quick! I just figured out how to do it: if you have, say, two languages, then create two identical rules (with different names, as per each language), and then click on the admin bar on each language, modifying the condition rules with each language’s category/product name, etc. (provided your taxonomies and product names are translated, too).

      Thread Starter codimex

      (@codimex)

      Thank you again!!! I take tons of ideas and ways to explore, given the limiting circumstances! Marking as resolved now. Have a nice week!

      Thread Starter codimex

      (@codimex)

      OK, after all this information, I have a bigger picture about the problem. I think it’s time to put this thread to an end. You’ve helped me faaaar beyond what I could expect, and I think my work now is trying to optimize the code as much as I can. The GTmetrix score is still poor, but I guess we’ve got the best we can from the LS cache plugin side (unless you come up with any other ideas).

      Thank you so much for your dedication. I’ll check with my webhost (you already know which one it is) about the crawler thing. I’ve deleted the Crawler settings, since the only setting which seems to somehow solve the issue is disabling object caching. Delaying JS scripts also works, but my maps don’t show up if I delay JS, so I prefer leaving it off. :”(

      Feel free to mark this as resolved if you have nothing to add from your side. Big thanks again!!!

      Thread Starter codimex

      (@codimex)

      Mmmm… Quite a few interesting paths open now. First, I’m getting this warning in the Cache Crawler Summary:

      The crawler feature is not enabled on the LiteSpeed server. Please consult your server admin or hosting provider.

      Should I ask for my webhost to perform any action?

      – Go to menu -> Cache -> Excludes tab and enter “age_gate” without quotation marks in textfield “Do Not Cache Query Strings”

      – Do a cache purge all

      – Give Feedback if done

      Ok, kept the Crawler simulation settings, disabled the Object cache, did the above thing. Languages are shown correctly, page loads twice before fully loaded. Not perfect, but acceptable.

      If you can do without QC, the solution is quite simple.

      Of course! I actually tried switching to Cloudflare free and keep QC for image optimization (webp), but my MX records stopped working (that’s another story) and reverted to QC. But my ideal scenario would be to switch to CF in combination of Litespeed Cache Plugin.

      Again, thanks for your willingness to help! Now I’m overwhelmed by your help!!!!

      Thread Starter codimex

      (@codimex)

      Oh, that’s so bad! :”( How is that the .htaccess settings have no impact on quic.cloud, and the other way around? Does it mean this website doomed?

      At this point, disabling “Object cache” is the only workaround to make things work (I’ve just did it, plus purging). Not the ideal scenario because it’s a key optimizing setting, but at least, the user gets the right language.

      What would you do, even in a bigger picture? Maybe switching from Complianz to another cookie manager? Switching Age verification to another solution? Should I ask my webhost to tune my server in some way?

      Thread Starter codimex

      (@codimex)

      Oh, thanks for your patience! As I said, I entered these settings, and yes, I purged the cache. Again, the language displayed when switching to another language shows the previous language prior to switching.

      (Also, the page looks like it loads twice before being fully loaded).

    Viewing 15 replies - 1 through 15 (of 176 total)