🇧🇾Belarus savage1974
Hi, t.maquin
Try to warm you caches with this command:
vendor/bin/drush --uri=https://your.domain warmer:enqueue cdn
vendor/bin/drush queue-run warmer
🇧🇾Belarus savage1974
Hi, trickfun!
Added pseudo-field with link - see new files in archive.
PS Thanks a lot all maintainers for this awesome module!
🇧🇾Belarus savage1974
Hi, all
For complete happiness the only thing missing is an update of the wishlist block via Ajax:
In commerce_wishlist.module make some changes:
1. add this row to "commerce_wishlist_add_to_wishlist_form_ajax" function:
$response->addCommand(new ReplaceCommand('.wishlist-block', getWishlistBlock()));
2. add 2 functions:
/**
* Get wishlist block.
*
* @return array|NULL
* Return render of wishlist block.
*/
function getWishlistBlock(): ?array {
$block_id = getWishlistBlockId();
if ($block_id !== FALSE) {
$block = Block::load($block_id);
$render = \Drupal::entityTypeManager()->getViewBuilder('block')
->view($block);
}
return $render ?? NULL;
}
/**
* Gets the machine name of a commerce wishlist block visible on the current page.
*
* Returns only the first Wishlist found.
*
* @return string|false
* Return id of the first commerce wishlist block found on current page.
* Returns FALSE if no commerce wishlist block is visible.
*/
function getWishlistBlockId(): string|false {
// Returns an array of regions each with an array of blocks.
$regions = \Drupal::service('block.repository')->getVisibleBlocksPerRegion();
// Iterate all visible blocks and regions.
foreach ($regions as $region) {
foreach ($region as $block) {
$plugin_id = $block->get('plugin');
// Check if this is a commerce wishlist block.
if ($plugin_id === 'commerce_wishlist') {
return $block->id();
}
}
}
return FALSE;
}