ffqa
June 10, 2021, 12:00am
#1
I am unsure how to display an additional tab on product variation pages, if it is a 'Variations as one product'.
I have a design/backend/templates/addons/my_addon/hooks/products/tabs_content.post.tpl
{include file="views/products/components/picker/picker.tpl"
input_name="my_addon_data[]"
item_ids=$my_addon
multiple=true
view_mode="external"
select_group_class="btn-toolbar"
}
For variations as separate products it works just fine.
design\backend\templates\addons\product_variations\hooks\products\tabs_content.override.tpl
has a condition
{if !$product_type->isFieldAvailable("tabs_content")}
{/if}
So I added app\addons\my_addon\schemas\product_variations\product_types.post.php with
use Tygh\Addons\ProductVariations\Product\Type\Type;
$schema[Type::PRODUCT_TYPE_VARIATION][‘tabs’][] = ‘my_addon’;
return $schema;
and it actually adds a tab... without content.
I'm not sure what to make of this. I'm new to CS-Cart and smarty, can anyone shed some light on this for me?
Hello,
Have you defined the tab on controller level?
In add-on you should create a controller /controllers/backend/products.post.php and add this mode there:
if ($mode == 'update') {
Registry::set('navigation.tabs.my_addon', array (
'title' => __('my_addon'),
'js' => true
));
} // end if
Also, make sure that you're cleaning cache regularly - templates are prone to be cached and therefore fields in tab may not be displaying correctly.
Best regards,
Robert
ffqa
June 14, 2021, 12:00am
#3
Thanks, I have the controller and cleared cache, but the problem persists.
ffqa
June 15, 2021, 12:00am
#5
The tab is visible for all variations, the tab content is visible on pages of 'variations as separate products' and does not exist on pages of 'variations as one product'.
ffqa
June 23, 2021, 12:00am
#6
As a workaround I simply put the content of my div in design\backend\templates\addons\my_addon\hooks\products\update_product_availability.post.tpl
Now it properly loads for all types of product variations.
However, 'variations as one product' is still giving me trouble. For this kind of product my data doesn't get saved/updated.
I have no explanation since it works for all other products that arent 'variations as one product'.