お世話になっております。
納品書の購入者住所を非表示にしたいです。
src\Eccube\Service\OrderPdfService.phpを継承しrenderOrderDataメソッドをオーバーライドし、住所設定の部分コメントアウトしたのですが住所が表示されてしまします。
子クラス住所の変数に別の値()を入れてみたのですが、住所の上にそのデータが重なって表示されてしまいます。
納品書PDFのをプラグインから非表示にすることは可能でしょうか。
ご存じでしたらご教授いただければ幸いです。
何卒宜しくお願い致します。
以下のサイトを参考にしました。
https://qiita.com/chihiro-adachi/items/b3bb70e6abbc0f824965プラグインのservices.yamlは以下の通りです。
services:
Plugin\sample\Service\OrderPdfServiceCustomizer:
public: false
autowire: true
decorates: Eccube\Service\OrderPdfService
<?php
namespace Plugin\sample\Service;
use Eccube\Common\EccubeConfig;
use Eccube\Entity\BaseInfo;
use Eccube\Entity\OrderItem;
use Eccube\Entity\Shipping;
use Eccube\Repository\BaseInfoRepository;
use Eccube\Repository\OrderPdfRepository;
use Eccube\Repository\OrderRepository;
use Eccube\Repository\ShippingRepository;
use Eccube\Twig\Extension\EccubeExtension;
use Eccube\Twig\Extension\TaxExtension;
use Eccube\Service\TaxRuleService;
use setasign\Fpdi\TcpdfFpdi;
class OrderPdfServiceCustomizer extends \Eccube\Service\OrderPdfService
{
/** @var OrderRepository */
protected $orderRepository;
/** @var ShippingRepository */
protected $shippingRepository;
/** @var OrderPdfRepository */
protected $orderPdfRepository;
/** @var TaxRuleService */
protected $taxRuleService;
/**
* @var EccubeConfig
*/
private $eccubeConfig;
/**
* @var EccubeExtension
*/
private $eccubeExtension;
/**
* @var TaxExtension
*/
private $taxExtension;
/**
* OrderPdfService constructor.
* @param EccubeConfig $eccubeConfig
* @param OrderRepository $orderRepository
* @param ShippingRepository $shippingRepository
* @param TaxRuleService $taxRuleService
* @param BaseInfoRepository $baseInfoRepository
* @param EccubeExtension $eccubeExtension
* @param TaxExtension $taxExtension
* @throws \Exception
*/
function __construct(EccubeConfig $eccubeConfig, OrderRepository $orderRepository, ShippingRepository $shippingRepository, TaxRuleService $taxRuleService, BaseInfoRepository $baseInfoRepository, EccubeExtension $eccubeExtension, TaxExtension $taxExtension) {
$this->eccubeConfig = $eccubeConfig;
$this->baseInfoRepository = $baseInfoRepository->get();
$this->orderRepository = $orderRepository;
$this->shippingRepository = $shippingRepository;
$this->taxRuleService = $taxRuleService;
$this->eccubeExtension = $eccubeExtension;
$this->taxExtension = $taxExtension;
parent::__construct($eccubeConfig, $orderRepository, $shippingRepository, $taxRuleService, $baseInfoRepository, $eccubeExtension, $taxExtension);
}
/**
* 購入者情報を設定する.
*
* @param Shipping $Shipping
*/
protected function renderOrderData(Shipping $Shipping)
{
// 基準座標を設定する
$this->setBasePosition();
// フォント情報のバックアップ
$this->backupFont();
// =========================================
// 購入者情報部
// =========================================
$Order = $Shipping->getOrder();
// 購入者都道府県+住所1
// $text = $Order->getPref().$Order->getAddr01();
// $text = $Shipping->getPref().$Shipping->getAddr01();
$text = "000000"; <-ダミーデータを入れるも重なって表示
$this->lfText(27, 47, $text, 10);
$this->lfText(27, 51, $Shipping->getAddr02(), 10); //購入者住所2
// 購入者氏名
if (null !== $Shipping->getCompanyName()) {
// 会社名
$text = $Shipping->getCompanyName();
$this->lfText(27, 57, $text, 11);
// 氏名
$text = $Shipping->getName01().' '.$Shipping->getName02().' 様';
$this->lfText(27, 63, $text, 11);
} else {
$text = $Shipping->getName01().' '.$Shipping->getName02().' 様';
$this->lfText(27, 59, $text, 11);
}
// =========================================
// お買い上げ明細部
// =========================================
$this->SetFont(self::FONT_SJIS, '', 10);
//ご注文日
$orderDate = $Order->getCreateDate()->format('Y/m/d H:i');
if ($Order->getOrderDate()) {
$orderDate = $Order->getOrderDate()->format('Y/m/d H:i');
}
$this->lfText(25, 125, $orderDate, 10);
//注文番号
$this->lfText(25, 135, $Order->getOrderNo(), 10);
// 総合計金額
if (!$Order->isMultiple()) {
$this->SetFont(self::FONT_SJIS, 'B', 15);
$paymentTotalText = $this->eccubeExtension->getPriceFilter($Order->getPaymentTotal());
$this->setBasePosition(120, 95.5);
$this->Cell(5, 7, '', 0, 0, '', 0, '');
$this->Cell(67, 8, $paymentTotalText, 0, 2, 'R', 0, '');
$this->Cell(0, 45, '', 0, 2, '', 0, '');
}
// フォント情報の復元
$this->restoreFont();
return parent::renderOrderData($Shipping);
}
}