Created
September 20, 2020 08:26
-
-
Save init90/29ade76dc9e0d49878e2e9f8f5d7a62f to your computer and use it in GitHub Desktop.
Hide price field for specific view mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_ENTITY_TYPE_view_alter() for 'commerce_product' entities. | |
*/ | |
function swimsports_commerce_commerce_product_view_alter(array &$build, EntityInterface $node, EntityViewDisplayInterface $display) { | |
// Hide price field. For some reason we cannot configure price visibility | |
// from UI. | |
if ($build['#view_mode'] === 'add_to_cart_confirmation_view') { | |
$build['variation_price']['#access'] = FALSE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment