バージョン選択

フォーラム

メニュー

オンライン状況

61 人のユーザが現在オンラインです。 (56 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 61
もっと...

サイト内検索

質問 > フロント機能 > 送料無料の条件

フロント機能

新規スレッドを追加する

スレッド表示 | 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
susumu
投稿日時: 2021/3/23 12:00
対応状況: −−−
一人前
登録日: 2018/12/17
居住地:
投稿: 104
送料無料の条件
EC-CUBEのバージョン アップデートで404

お世話になります。
通常の送料設定で沖縄以外の送料を全て800円、沖縄だけ1700円と設定し
10000円以上の買い物で沖縄以外の送料を無料、沖縄は800円としたいのですがどのようにしたら良いのでしょうか?

以前にも同様の投稿をしたのですが404にアップデートしてから機能しなくなりました。
スキルが無いので出来ましたら具体的にどこをどのように直すかをご教授いただけると幸いです。
umebius
投稿日時: 2021/3/23 22:37
対応状況: −−−
登録日: 2016/7/22
居住地:
投稿: 2085
Re: 送料無料の条件
アップデートしても基本は同じだと思いますが、
以前はどのように修正されたのでしょうか?

$Order->getPref()->getId()が沖縄の47であるかどうかで送料無料にするか、800円にするか、条件分岐してやれば良いかと思います。

通常はsetQuantity(0)の部分で個数を0にすることで送料無料にしています。

https://github.com/EC-CUBE/ec-cube/blob/4.0.4/src/Eccube/Service/PurchaseFlow/Processor/DeliveryFeeFreeByShippingPreprocessor.php#L81

このカスタマイズはそれほど簡単なものでもないので、ご自身で難しいようであればエンジニアの方に依頼されることもご検討された方が良いかと思います。


----------------
EC-CUBEカスタマイズ・高速化・脆弱性対策・SEO ご相談ください。

2系・3系から4系へのバージョンアップ実績豊富

susumu
投稿日時: 2021/3/25 10:31
対応状況: −−−
一人前
登録日: 2018/12/17
居住地:
投稿: 104
Re: 送料無料の条件
ありがとうございます。
以前はこちら https://a-zumi.net/eccube4-no-free-shipping-pref/ を参考に

<?php

/*
* Copyright (C) 2019 Akira Kurozumi <info@a-zumi.net>;.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/

namespace Customize\Service\PurchaseFlow\Processor;

use Eccube\Annotation\ShoppingFlow;
use Eccube\Entity\BaseInfo;
use Eccube\Entity\ItemHolderInterface;
use Eccube\Entity\Order;
use Eccube\Repository\BaseInfoRepository;
use Eccube\Repository\Master\PrefRepository;
use Eccube\Service\PurchaseFlow\ItemHolderPreprocessor;
use Eccube\Service\PurchaseFlow\Processor\DeliveryFeePreprocessor;
use Eccube\Service\PurchaseFlow\PurchaseContext;

/**
* 送料無料条件を適用する.
* お届け先ごとに条件判定を行う.
*
* @ShoppingFlow()
*/
class DeliveryFeeFreeByShippingPreprocessor implements ItemHolderPreprocessor
{
/**
* @var BaseInfo
*/
protected $BaseInfo;

/**
* @var PrefRepository
*/
private $prefRepository;

public function __construct(
BaseInfoRepository $baseInfoRepository,
PrefRepository $prefRepository
) {
$this->BaseInfo = $baseInfoRepository->get();
$this->prefRepository = $prefRepository;
}

/**
* @param ItemHolderInterface $itemHolder
* @param PurchaseContext $context
*/
public function process(ItemHolderInterface $itemHolder, PurchaseContext $context)
{
if (!($this->BaseInfo->getDeliveryFreeAmount() || $this->BaseInfo->getDeliveryFreeQuantity())) {
return;
}

// Orderの場合はお届け先ごとに判定する.
if ($itemHolder instanceof Order) {
// 送料無料条件適用を除外する都道府県を指定
$noFreePref = '沖縄県';

/** @var Order $Order */
$Order = $itemHolder;
foreach ($Order->getShippings() as $Shipping) {
$isFree = false;
$total = 0;
$quantity = 0;
foreach ($Shipping->getProductOrderItems() as $Item) {
$total += $Item->getPriceIncTax() * $Item->getQuantity();
$quantity += $Item->getQuantity();
}
// 送料無料(金額)を超えている
if ($this->BaseInfo->getDeliveryFreeAmount()) {
if ($total >= $this->BaseInfo->getDeliveryFreeAmount()) {
$isFree = true;
}
}
// 送料無料(個数)を超えている
if ($this->BaseInfo->getDeliveryFreeQuantity()) {
if ($quantity >= $this->BaseInfo->getDeliveryFreeQuantity()) {
$isFree = true;
}
}
if ($isFree) {
foreach ($Shipping->getOrderItems() as $Item) {
if ($Item->getProcessorName() == DeliveryFeePreprocessor::class) {
// 送料無料条件適用を除外する都道府県とマッチしたら送料明細の数量を1とする
if ($Shipping->getPref() == $this->prefRepository->findOneBy(['name' => $noFreePref])) {
$Item->setQuantity(1);
// 都道府県別送料設定で設定した送料と別の送料にしたい場合はこちらを追加
// $Item->setPrice(800);
}
}
}
}
}
}
}
}

をCustomize/Service/PurchaseFlow/Processorディレクトリに設定しました。
404で書き換わったファイルを元のファイルに戻して同様のことをするとカートに入れた後エラーが出たのですが、今住所を沖縄にして実際に買い物をしてみたら、エラーにはなりませんでしたが税込11000円以上の買い物でも割引送料になりませんでした。
balisys
投稿日時: 2023/11/13 18:26
対応状況: −−−
仙人
登録日: 2020/7/5
居住地:
投稿: 397
Re: 送料無料の条件
dumpを取りながら、処理の流れを追うことは可能でしょうか。
dumpで変数にセットされている値を見ながら処理を追うことで原因の特定に近づけるかと思います。
スレッド表示 | 新しいものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,307名です
総投稿数は109,692件です

投稿数ランキング

1
seasoft
7365
2
468
3217
3
AMUAMU
2712
4
nanasess
2303
5
umebius
2085
6
yuh
1818
7
h_tanaka
1610
8
red
1568
9
mcontact
1240
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
796
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.