Forum Replies Created
-
AuthorPosts
-
levipeParticipantYes Steve,
I understand the code has been altered.
But, as I wrote, this creates issues with the filter in WooCommerce.
A related field in a product cannot be filtered with WooCommerce anymore.That’s why I suggested the above modification to the code.
C
levipeParticipantSo, this is what I added to the function relate() in class-piklist-form.php to establish the 2-way relationship
add_metadata($object['scope_to'], $from, $meta_key, $to); // added CG 22/7/2018 add_metadata($object['scope_to'], $to, $meta_key, $from);But, it’d be better if Steve could add that to the core code
levipeParticipantSo,
I got it working… half.
The parts-code looks like this:
piklist('field', array( 'type' => 'checkbox', 'label' => 'Regions', 'choices' => piklist( get_posts( array( 'suppress_filters' => false, 'post_status' => publish, 'numberposts' => -1, 'post_type' => 'region' )), array( 'ID', 'post_title' ) ), 'relate' => array( 'scope' => 'post' ), 'attributes' => array( 'class' => 'multiple' ) ));and yes, the relationships are stored, like this:
post_ID: 41 meta_key: __relate_post meta_value: 1707post_ID is a post of post_type region and meta_value is a post holding a product.
But, the symmetric relationship is not stored!
post_ID: 1707 meta_key: __relate_post meta_value: 41is not present in the DB.
This hasn’t consequences on my layout (working with has_post and post_belongs as need be), but the queries in WooCommerce don’t work anymore because of the lacking symmetric relationship post. In this instance, I cannot query on ‘region’.
levipeParticipantup
levipeParticipantup
levipeParticipantsolved. Was a setting in WPML
levipeParticipantWell,
found out what happened.
Results get saved only if there is more than one custom post in the custom post typeExample:
if I’d have only one grape (eg Pinot Noir) in the grape post type, then the relation won’t save.
If I have more than one, then the save is performed.I guess this might be one for the bug list
Charles
-
AuthorPosts