umbertoZ
Support threads created in the last 30 days: 1
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
jQuery after AJAX form submit
Started by: umbertoZ in: Toolset Professional Support |
2 | 4 | 3 weeks, 4 days ago | ||
Disable and remove Astra theme pagination
Started by: umbertoZ in: Toolset Professional Support |
2 | 4 | 1 month, 2 weeks ago | ||
Custom pagination URLs
Started by: umbertoZ in: Toolset Professional Support |
2 | 5 | 1 month, 3 weeks ago | ||
Automatically delete connections when a child is trashed
Started by: umbertoZ
in: Toolset Professional Support
Problem: The customer created a many-to-many relationship between posts and products using Toolset and WooCommerce. When a connected product is "trashed," the connection is not automatically deleted, resulting in empty product cells in the grid view. The customer wanted a way to either filter out intermediary posts with trashed children or automatically delete the connections when a product is trashed. Solution: We provided a custom function using the wp_trash_post hook to automatically disconnect any intermediary posts associated with a product when it is trashed. The function also initially moved the intermediary posts to the trash, but this behavior was corrected to ensure only the connections were deleted without affecting the original post status. The code was updated to handle multiple relationships and ensure the associated posts remain published even after a product is trashed. Final code: The function disconnects intermediary posts while ensuring that the associated posts remain published. add_action('wp_trash_post', 'delete_relationships_on_trashed_product', 101, 2); function delete_relationships_on_trashed_product($post_id, $previous_status) { // Get the post object based on the post ID $post = get_post($post_id); // Ensure we have a valid post object and that it is of type 'product' if ($post && $post->post_type === 'product') { // Define the relationship slugs to check $relationship_slugs = ['post-product', 'post-product-2', 'post-product-3']; // Loop through each relationship slug and handle the disconnection foreach ($relationship_slugs as $relationship_slug) { // Get all intermediary posts related to this product for the current relationship slug $related_intermediary_posts = toolset_get_related_posts( $post_id, // ID of the post to get relationships from $relationship_slug, // Relationship slug 'child', // Role of $post_id in this relationship -1, // Limit to get all related posts 0, // Offset [], // Additional arguments 'post_id', // Return type, we want the post IDs 'parent' // We want to get the parent posts related to this child ); // Loop through each intermediary post and delete the relationship if (!empty($related_intermediary_posts)) { foreach ($related_intermediary_posts as $intermediary_post_id) { // Disconnect the intermediary post $disconnect_result = toolset_disconnect_posts($relationship_slug, $intermediary_post_id, $post_id); // After disconnecting, ensure the parent post remains published // Get the parent post object $parent_post = get_post($intermediary_post_id); // Check if the post status is not 'publish' and update it to 'publish' if ($parent_post && $parent_post->post_status !== 'publish') { wp_update_post([ 'ID' => $parent_post->ID, 'post_status' => 'publish' ]); } } } } } } Relevant Documentation: |
2 | 9 | 2 months ago | ||
Relatioship Posts-Products search by title and SKU
Started by: umbertoZ in: Toolset Professional Support |
2 | 4 | 2 months, 1 week ago | ||
Types error and conflict
Started by: umbertoZ in: Toolset Professional Support |
2 | 6 | 4 months, 1 week ago | ||
AJAX pagination for Woocommerce featured products View
Started by: umbertoZ
in: Toolset Professional Support
Problem: Solution: Relevant Documentation: |
2 | 7 | 4 months, 2 weeks ago | ||
Conflict Toolset with Astra Pro
Started by: umbertoZ in: Toolset Professional Support |
1 | 2 | 5 months, 1 week ago | ||
Woocommerce custom ordering
Started by: umbertoZ in: Toolset Professional Support |
1 | 2 | 6 months ago | ||
Product Image Gallery block
Started by: umbertoZ in: Toolset Professional Support |
2 | 3 | 6 months, 1 week ago | ||
Broken Block views
Started by: umbertoZ in: Toolset Professional Support |
2 | 2 | 8 months ago | ||
Shortcode as attribute of a view
Started by: umbertoZ in: Toolset Professional Support |
2 | 3 | 8 months ago | ||
Pause the development news
Started by: umbertoZ in: Toolset Professional Support |
2 | 2 | 8 months, 2 weeks ago | ||
Astra Theme override archive's "Display items per page" for pagination
Started by: umbertoZ in: Toolset Professional Support |
2 | 2 | 9 months, 3 weeks ago | ||
Split: Custom search problem with checkbox label translation – filter not working for taxonomy
Started by: umbertoZ in: Toolset Professional Support |
2 | 5 | 9 months, 4 weeks ago |