我有一个带有市场(多个商店)的Drupal 8网站。
我想在“结帐窗格”的“审阅”步骤中显示带有销售条款的复选框。
当前,如果我在2家商店中订购,这将创建2个购物车(每个商店1个)。
每个商店的销售条款均可通过以下网址访问:
/store/ID/cgv
下面的代码有效,但是我需要用当前商店(下订单的商店)的ID替换['commerce_store' => 3]
。
如何执行此操作?
示例:
如果我在商店A中订购产品,它将创建一个购物车。
如果我在商店B中订购产品,它将创建第二个购物车。
每个购物车都必须在“查看”步骤中显示购物篮所属商店的一般销售条件。
<?php
namespace Drupal\commerce_agree_cgv\Plugin\Commerce\CheckoutPane;
use Drupal\Core\Form\FormStateInterface;
use Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneBase;
use Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneInterface;
use Drupal\Core\Link;
/**
* Provides the completion message pane.
*
* @CommerceCheckoutPane(
* id = "agree_cgv",
* label = @Translation("Agree CGV"),
* default_step = "review",
* )
*/
class AgreeCGV extends CheckoutPaneBase implements CheckoutPaneInterface {
/**
* {@inheritdoc}
*/
public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
$link = Link::createFromRoute('the general terms and conditions of business', 'entity.commerce_store.canonical', ['commerce_store' => 3], ['attributes' => ['target' => '_blank']])->toString();
$pane_form['cgv'] = [
'#type' => 'checkbox',
'#default_value' => FALSE,
'#title' => $this->t('I have read and accept @cgv.', ['@cgv' => $link]),
'#required' => TRUE,
'#weight' => $this->getWeight(),
];
return $pane_form;
}
}