Я написал следующий код для замены кнопки «Добавить в корзину» (Ajouter au panier) на кнопку «Продажи в автономном режиме».
Не работает. Вместо замены кнопки он добавляет новую.
Как заменить кнопку «Добавить в корзину»?
<?php
/**
* @file
* Hook implementations of commerce_add_to_cart_access module.
*/
use Drupal\commerce_product\Entity\ProductType;
use Drupal\commerce_product\Entity\ProductVariationType;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
function commerce_add_to_cart_access_form_commerce_order_item_add_to_cart_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
// Code to get store owner.
$current_store = \Drupal::service('commerce_store.current_store');
$owner = $current_store->getStore()->getOwner();
if (!$owner->hasRole('marchand_premium')) {
// Overwrite the whole form markup.
unset ($form['submit'])
$form['submit'] = [
'#type' => 'inline_template',
'#template' => '<button type="button" class="btn btn-success" disabled="disabled">Offline sales</button>',
];
}
}
https://www.s1biose.com/produit/savon-artisanal-bio-la-cannelle
введите описание изображения здесь