Skip to content

Instantly share code, notes, and snippets.

@aimahdi
Last active November 26, 2025 07:07
Show Gist options
  • Select an option

  • Save aimahdi/1d5c976f7b4943941e12eafe70b13ae1 to your computer and use it in GitHub Desktop.

Select an option

Save aimahdi/1d5c976f7b4943941e12eafe70b13ae1 to your computer and use it in GitHub Desktop.
<?php
add_filter('fluent_cart/single_product/variation_view_type', function ($viewType, $data) {
$textOnlyProducts = [];
$imageOnlyProducts = [];
$bothOnlyProducts = [];
$productId = $data['product']->ID;
if(in_array($productId, $textOnlyProducts)) {
return 'text';
}elseif (in_array($productId, $imageOnlyProducts)) {
return 'image';
}elseif (in_array($productId, $bothOnlyProducts)) {
return 'both';
}
return $viewType;
}, 10, 2);
add_filter('fluent_cart/single_product/variation_column_type', function ($columnType, $data) {
$oneColumnProducts = [];
$twoColumnProducts = [];
$threeColumnProducts = [];
$fourColumnProducts = [];
$masonryProducts = [];
$productId = $data['product']->ID;
if(in_array($productId, $oneColumnProducts)) {
return 'one';
}elseif (in_array($productId, $twoColumnProducts)) {
return 'two';
}elseif (in_array($productId, $threeColumnProducts)) {
return 'three';
}elseif (in_array($productId, $fourColumnProducts)) {
return 'four';
}elseif (in_array($productId, $masonryProducts)) {
return 'masonry';
}
return $columnType;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment