Skip to content

Commit

Permalink
Merge pull request #3399 from kengo-kamon/experimental/261
Browse files Browse the repository at this point in the history
#261 【ご注文手続き】お届け日のプルダウンに曜日も出したい
  • Loading branch information
ryo-endo committed Jul 26, 2018
2 parents 048f3e7 + af40c1c commit a2a3228
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/Eccube/Form/Type/Shopping/ShippingType.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,18 @@ function (FormEvent $event) {
new \DateTime($minDate + $this->eccubeConfig['eccube_deliv_date_end_max'].' day')
);

// 曜日設定用
$dateFormatter = \IntlDateFormatter::create(
'ja_JP@calendar=japanese',
\IntlDateFormatter::FULL,
\IntlDateFormatter::FULL,
'Asia/Tokyo',
\IntlDateFormatter::TRADITIONAL,
'E'
);

foreach ($period as $day) {
$deliveryDurations[$day->format('Y/m/d')] = $day->format('Y/m/d');
$deliveryDurations[$day->format('Y/m/d')] = $day->format('Y/m/d').'('.$dateFormatter->format($day).')';
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Resource/template/default/Mypage/history.twig
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ file that was distributed with this source code.
</div>
<div class="ec-definitions--soft">
<dt>{{'mypage.history.detail.label.shipping_date'|trans}} : </dt>
<dd>{{ Shipping.shipping_delivery_date|date_format|default('admin.shipping.edit.719'|trans) }}</dd>
<dd>{{ Shipping.shipping_delivery_date|date_day_with_weekday|default('admin.shipping.edit.719'|trans) }}</dd>
</div>
<div class="ec-definitions--soft">
<dt>{{'mypage.history.detail.label.shipping_time'|trans}} : </dt>
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Resource/template/default/Shopping/confirm.twig
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ $(function() {
</div>
<div class="ec-select ec-select__delivery">
<label>お届け日</label>
{{ Order.Shippings[idx].shipping_delivery_date? Order.Shippings[idx].shipping_delivery_date|date_day :"指定なし" }}
{{ Order.Shippings[idx].shipping_delivery_date? Order.Shippings[idx].shipping_delivery_date|date_day_with_weekday :"指定なし" }}
{{ form_widget(form.Shippings[idx].shipping_delivery_date, {'type': 'hidden'}) }}
</div>
<div class="ec-select ec-select__time">
Expand Down
27 changes: 27 additions & 0 deletions src/Eccube/Twig/Extension/IntlExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function getFilters()
new TwigFilter('date_day', [$this, 'date_day'], ['needs_environment' => true]),
new TwigFilter('date_min', [$this, 'date_min'], ['needs_environment' => true]),
new TwigFilter('date_sec', [$this, 'date_sec'], ['needs_environment' => true]),
new TwigFilter('date_day_with_weekday', [$this, 'date_day_with_weekday'], ['needs_environment' => true]),
];
}

Expand Down Expand Up @@ -90,4 +91,30 @@ public function date_sec(Environment $env, $date)

return \twig_localized_date_filter($env, $date, 'medium', 'medium');
}

/**
* @param Environment $env
* @param $date
*
* @return bool|string
*/
public function date_day_with_weekday(Environment $env, $date)
{
if (!$date) {
return '';
}

$date_day = \twig_localized_date_filter($env, $date, 'medium', 'none');
// 曜日
$dateFormatter = \IntlDateFormatter::create(
'ja_JP@calendar=japanese',
\IntlDateFormatter::FULL,
\IntlDateFormatter::FULL,
'Asia/Tokyo',
\IntlDateFormatter::TRADITIONAL,
'E'
);

return $date_day.'('.$dateFormatter->format($date).')';
}
}

0 comments on commit a2a3228

Please sign in to comment.