public function canAddProductPayment(\Eccube\Entity\Master\ProductType $ProductType)
{
$deliveries = $this->entityManager->getRepository('\\Eccube\\Entity\\Delivery')->findBy(array('ProductType' => $ProductType));
// 支払方法を取得
$payments = $this->entityManager->getRepository('Eccube\\Entity\\Payment')->findAllowedPayments($deliveries);
if ($this->getCart()->getTotalPrice() < 1) {
// カートになければ支払方法を全て設定
$this->getCart()->setPayments($payments);
return true;
}
// カートに存在している支払方法と追加された商品の支払方法チェック
$arr = array();
foreach ($payments as $payment) {
foreach ($this->getCart()->getPayments() as $p) {
if ($payment['id'] == $p['id']) {
$arr[] = $payment;
break;
}
}
}
if (count($arr) > 0) {
$this->getCart()->setPayments($arr);
return true;
}
// 支払条件に一致しない
return false;
}