From 692bd3e30c5549c53ae03a983f113aecdc2e00d4 Mon Sep 17 00:00:00 2001 From: "Anton.AE" Date: Tue, 8 Jul 2025 14:09:37 +0300 Subject: [PATCH] Andrei | fix upsales setting --- .../shop/components/single-product/component-controller.php | 5 +---- .../cosmopet/templates/_pages/shop/product-single.twig | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/wp-content/themes/cosmopet/modules/shop/components/single-product/component-controller.php b/wp-content/themes/cosmopet/modules/shop/components/single-product/component-controller.php index db257b4..db2afe7 100644 --- a/wp-content/themes/cosmopet/modules/shop/components/single-product/component-controller.php +++ b/wp-content/themes/cosmopet/modules/shop/components/single-product/component-controller.php @@ -132,8 +132,7 @@ add_filter('timber/context', function ($context) use ($context_for_twig) { $context['product'] = $product; $context['related_products'] = array(); - $related_products_ids = wc_get_related_products($product_id, 5); - + $related_products_ids = $product->get_upsell_ids(); if ($related_products_ids) { foreach ($related_products_ids as $related_id) { $related_product = wc_get_product($related_id); @@ -142,8 +141,6 @@ add_filter('timber/context', function ($context) use ($context_for_twig) { } } } - - if (class_exists('WCS_ATT_Product_Schemes')) { $schemes = WCS_ATT_Product_Schemes::get_subscription_schemes($product); $context['has_subscription_options'] = !empty($schemes); diff --git a/wp-content/themes/cosmopet/templates/_pages/shop/product-single.twig b/wp-content/themes/cosmopet/templates/_pages/shop/product-single.twig index 70502eb..adcbcc8 100644 --- a/wp-content/themes/cosmopet/templates/_pages/shop/product-single.twig +++ b/wp-content/themes/cosmopet/templates/_pages/shop/product-single.twig @@ -341,8 +341,7 @@
- {% set recommended_products = function('get_field', 'recommended_products', product.id) %} - {% set related_products = recommended_products ? recommended_products : function('wc_get_related_products', product.id, 4) %} + {% if related_products %}
@@ -365,7 +364,7 @@ {% for related_product in related_products %}
- {% set post_id = related_product.ID is defined ? related_product.ID : related_product %} + {% set post_id = related_product.id %} {% set wc_product = TimberPost(post_id) %} {% if wc_product %} {% include '_blocks/shop/archive-product-tease.twig' with {post: wc_product} %}