Accueil › Toolset Professional Support › [Résolu] Timetable (schedule, opening hours)
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
Marqué : Types plugin
Ce sujet contient 34 réponses, a 4 voix.
Dernière mise à jour par Ljuba Il y a 6 années et 2 mois.
Assisté par: Nigel.
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
Hi Ljuba
I had some time to look at this and have worked on updating the abierto shortcode.
First please note that there is a current open issue which prevent this from working:
You need to download the patch and overwrite the existing file in the types plugin. But! Note that the correct folder is plugins/types/vendor/toolset/toolset-common/inc/m2m/association/query/condition/ (I've asked for the erratum to be corrected).
You can then update the abierto shortcode as follows:
add_shortcode( 'abierto', function(){ global $post; // get UTC offset for current WP timezone $offset = get_option('gmt_offset'); $now = date( "H", time() + $offset * 60 * 60 ); // current locale hour in 24H format // get horario posts related to current alojamiento $horarios = toolset_get_related_posts( $post->ID, // current post 'alojamiento-horario', // relationship slug 'parent', // current post is parent of horario 1, // limit to single result 0, // offset array( // get the horario post for today 'meta_key' => 'wpcf-dias-de-la-semana', 'meta_value' => date( "N", time() + $offset * 60 * 60 ), 'compare' => '=' ), 'post_id', // return post id 'child' // role to return ); $estado = get_post_meta( $horarios[0], 'wpcf-estado-de-apertura', true ); if ( $estado == 2 ) { return "Cerrado"; } $jornada = get_post_meta( $horarios[0], 'wpcf-jornada', true ); if ( $jornada == 1 ) { $apertura = get_post_meta( $horarios[0], 'wpcf-hora-de-apertura', true ); $cierre = get_post_meta( $horarios[0], 'wpcf-hora-de-cierre', true ); if ( $now >= $apertura && $now < $cierre ) { return "Abierto!"; } else { return "Cerrado"; } } elseif ( $jornada == 2 ) { $apertura1 = get_post_meta( $horarios[0], 'wpcf-hora-de-apertura-de-la-manana', true ); $cierre1 = get_post_meta( $horarios[0], 'wpcf-hora-de-cierre-de-la-manana', true ); $apertura2 = get_post_meta( $horarios[0], 'wpcf-hora-de-apertura-de-la-tarde', true ); $cierre2 = get_post_meta( $horarios[0], 'wpcf-hora-de-cierre-de-la-tarde', true ); if ( ( $now >= $apertura1 && $now < $cierre1 ) || ( $now >= $apertura2 && $now < $cierre2 ) ) { return "Abierto!"; } else { return "Cerrado"; } } // catch all return "Cerrado*"; });
The original version was written for Types 2, this is updated to use Types 3 and the relationships API.
I also updated it so that it will work correctly for the local timezone.
I tested it on a local copy of your site and I'm fairly confident it works correctly now.
Note also that you have a View "Horario de apertura", ordered by the day of the week. This is missing a Query Filter for the parent alojamiento, so it is showing all horario posts (though at the moment you only have seven, one for each day). Otherwise that appears to work fine to display the basic horario information.
As before I've left you to work out how you will handle the horarios for la madrugada. You have enough in the current shortcode to act as a starting point for any further customisations you'll need.
Please, after patching Types, check that it works as currently described.
I need to remind you that this is entirely custom code which is outside our support policy, and between the original ticket and this one I've now spent several hours on this issue, and I can't really spend any more time on it, so if you need to customise it further and can't do that yourself, you'll need to recruit a developer for help.
I didn't really understand the question in your last update, but hopefully on the basis of this update the answer will be clear to yourself.
Good luck!
OK.
1) FIRST, thanks for effort.
2) I patched.
3) I only separated place of the ABIERTO appearance (place where appear shortcode [abierto] and placed that in header (schedule is down in Politicas section). So, that is visual and should not to affect.
4) It looks broken
WordPress database error: [Unknown column 'wp_postmeta_1' in 'where clause'] SELECT DISTINCT associations.child_id AS child_id FROM wp_toolset_associations AS associations JOIN wp_toolset_relationships AS relationships ON ( associations.relationship_id = relationships.id ) JOIN wp_posts AS wp_posts_1 ON (wp_posts_1.ID = parent_id) JOIN wp_posts AS wp_posts_2 ON (wp_posts_2.ID = child_id) LEFT JOIN wp_postmeta AS wp_postmeta_1 ON (wp_postmeta_1.post_id = child_id AND wp_postmeta_1.meta_key = 'wpcf-dias-de-la-semana') WHERE ( associations.relationship_id = 16 ) AND ( parent_id = 198 ) AND ( wp_postmeta_1 = '1' ) AND ( ( ( wp_posts_1.post_status IN ( 'publish', 'draft', 'pending', 'private' ) ) AND ( wp_posts_2.post_status IN ( 'publish', 'draft', 'pending', 'private' ) ) ) ) AND ( relationships.is_active = 1 ) LIMIT 1 OFFSET 0 Notice: Undefined offset: 0 in /opt/bitnami/apps/canoaturinfo/htdocs/wp-content/plugins/code-snippets/php/snippet-ops.php(352) : eval()'d code on line 25 Notice: Undefined offset: 0 in /opt/bitnami/apps/canoaturinfo/htdocs/wp-content/plugins/code-snippets/php/snippet-ops.php(352) : eval()'d code on line 31
AND IT ALWAYS SHOW CERRADO>
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
That error is what the patch fixes, so that seems to have gone wrong.
I just use a file manager plugin to apply the patch myself, can you test again? (I don't have FTP details any longer and can't see the debug.log.)
I made a copy of your site this morning where I tested the updated version of the shortcode and it was working, so it should be possible to get it to work on your live site.
To be honest, I didn't do it trough FTP, I patched last Types and than re-install it (simple way). But now I can do it from scratch, re-install clean Types and than patch it (but, I can't see difference in process).
Sorry, I missed what you did. I can enable debug or if you want open private to send you the PPK and all data for access.
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
Here's a private reply, I just need the FTP details...
Same.
I f you think that I'm not patched well the Types, it is simple and easy to patch it on your PC and you have full access to uninstall existing Types and replace it with patched, right?
Debug is enabled, so ... what else, can i to do?
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
As I can't access FTP I can't check it, but if you are still getting the WordPress database error then we'll maybe need to wait for the next Types update.
On my local copy of your site the patched version of Types is working correctly, so I expect this should work on your site after the next Types update.
Well, FTP is only for upload the patch or patched version of Types (can be done in different way). But I'm complete positive that that is just fine done. Debug is enabled (but snippet is disabled) and cna be ssen how problem exists still (just enable snippet and you will see).
So, I guess, only to wait update. You mean that this patch will come with update of Types, right?
Hi,
This is to notify you that Nigel is off today. he will continue working on your ticket once he gets back tomorrow.
Thanks.
Thanks for info.
Hi Nigel,
I think that is the time to decide what to do finally.
1) I trough backup migrate original site to domain new.canoaturinfo.com and on canoaturinfo.com is now complete fresh install with patched Types (both are with same credentials for you).
2) You can see that on booth I have return of shortcode as "Cerrado*" (your last part of function), for whatever time settings.
Should I quit from idea to display real time schedule and close the ticket (it will not be "end of the world"), or you have some idea/suggestion?
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
I was waiting for the Types update so we don't have to worry about whether the patch has been applied properly, but the queue for testing CRED and Views has taken longer than expected, and Types QA testing is only beginning now, so won't be out before next week.
I just checked again and it is working fine on my local copy of your site (screenshot).
Hostal Bumba opened 14 minutes ago, and you can see the horario post that corresponds to today.
If your live site shows "Cerrado*" then you can see from the shortcode that that is a catch-all in case the other conditions were not met.
add_shortcode( 'abierto', function(){ global $post; // get UTC offset for current WP timezone $offset = get_option('gmt_offset'); $now = date( "H", time() + $offset * 60 * 60 ); // current locale hour in 24H format // get horario posts related to current alojamiento $horarios = toolset_get_related_posts( $post->ID, // current post 'alojamiento-horario', // relationship slug 'parent', // current post is parent of horario 1, // limit to single result 0, // offset array( // get the horario post for today 'meta_key' => 'wpcf-dias-de-la-semana', 'meta_value' => date( "N", time() + $offset * 60 * 60 ), 'compare' => '=' ), 'post_id', // return post id 'child' // role to return ); $estado = get_post_meta( $horarios[0], 'wpcf-estado-de-apertura', true ); if ( $estado == 2 ) { return "Cerrado"; } $jornada = get_post_meta( $horarios[0], 'wpcf-jornada', true ); if ( $jornada == 1 ) { $apertura = get_post_meta( $horarios[0], 'wpcf-hora-de-apertura', true ); $cierre = get_post_meta( $horarios[0], 'wpcf-hora-de-cierre', true ); if ( $now >= $apertura && $now < $cierre ) { return "Abierto!"; } else { return "Cerrado"; } } elseif ( $jornada == 2 ) { $apertura1 = get_post_meta( $horarios[0], 'wpcf-hora-de-apertura-de-la-manana', true ); $cierre1 = get_post_meta( $horarios[0], 'wpcf-hora-de-cierre-de-la-manana', true ); $apertura2 = get_post_meta( $horarios[0], 'wpcf-hora-de-apertura-de-la-tarde', true ); $cierre2 = get_post_meta( $horarios[0], 'wpcf-hora-de-cierre-de-la-tarde', true ); if ( ( $now >= $apertura1 && $now < $cierre1 ) || ( $now >= $apertura2 && $now < $cierre2 ) ) { return "Abierto!"; } else { return "Cerrado"; } } // catch all return "Cerrado*"; });
That suggests that $jornada is neither 1 nor 2, which is where to start looking if something is going wrong.
I would add some messages to echo the variables such as $jornada to the error log as they are created which should enable you to identify when something is unexpected and hopefully see why.
Thanks for info. I have no problem to wait update. I just asked to know sshould we wait yet or close the ticket. So, I will just wait for your (echo variables) update.
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
Hi Ljuba
Just a quick note to say that the Types update has been published, if you want to update and try again to see if we can get past the problem with applying the patch which worked okay on my copy of your site but not on yours.