現在ローカル環境でwordpressのプラグインのwelcartでECサイト構築を勉強しています。
ここで聞くのは場違いかもしれませんが、知恵を貸してほしく思います。開発フォーラムには質問済みです。下記が質問内容です。
リンク内容
welcartのカートページの発送・支払方法のページをカスタマイズしています。解決したいことは、このページに出てくるカスタムオーダーフィールドで必須に設定したものが効かないことです。
まずカスタマイズの内容として「別の発送先の指定」をチェックしたときにでてくる入力フォームはお客様情報入力で使われる入力フォームでした。これはフィルターフックをつかって、出力している関数内をコピーしてif分岐で入力フォームを別にすることができました。
その次に入力フォームに使われているバリデーションの関数をフィルターフックで、名前だけ必須にしました。下記がそのコードです。
add_filter('usces_filter_delivery_check', 'my_filter_delivery_check2', 10); function my_filter_delivery_check2($mes) { $mes = ''; if ( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) { if ( WCUtils::is_blank($_POST["delivery"]["name1"]) ) $mes .= "届け先名を入力してください<br />"; // if ( trim($_POST["delivery"]["name3"]) == "" && USCES_JP ) // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />"; /*if ( WCUtils::is_blank($_POST["delivery"]["zipcode"]) ) $mes .= __('postal code is not correct', 'usces') . "<br />"; if ( $_POST["delivery"]["pref"] == __('-- Select --', 'usces') || $_POST["delivery"]["pref"] == '-- Select --' ) $mes .= __('enter the prefecture', 'usces') . "<br />"; if ( WCUtils::is_blank($_POST["delivery"]["address1"]) ) $mes .= __('enter the city name', 'usces') . "<br />"; if ( WCUtils::is_blank($_POST["delivery"]["address2"]) ) $mes .= __('enter house numbers', 'usces') . "<br />"; if ( WCUtils::is_blank($_POST["delivery"]["tel"]) ) $mes .= __('enter phone numbers', 'usces') . "<br />";*/ } return $mes; }
このやり方もコメントアウトしているだけなので、いい方法ではないと思います。とりあえずこの形で名前だけ入力チェックを行うことができました。
ただこの関数をfunctions.phpに書いたら、このwelcartが用意しているカスタムオーダーフィールドの必須が効かなくなってしまいました。
どこか別にカスタムオーダーフィールドの入力チェックが存在しているのか探しています。
何かご存知の方がいれば、ファイル名か関数名など教えて頂きたいと思います。ご教授お願いします。
追加 下記の関数が入力チェックをしている?
function delivery_check() { $mes = ''; if ( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) { if ( WCUtils::is_blank($_POST["delivery"]["name1"]) ) $mes .= __('Name is not correct', 'usces') . "<br />"; // if ( trim($_POST["delivery"]["name3"]) == "" && USCES_JP ) // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />"; if ( WCUtils::is_blank($_POST["delivery"]["zipcode"]) ) $mes .= __('postal code is not correct', 'usces') . "<br />"; if ( $_POST["delivery"]["pref"] == __('-- Select --', 'usces') || $_POST["delivery"]["pref"] == '-- Select --' ) $mes .= __('enter the prefecture', 'usces') . "<br />"; if ( WCUtils::is_blank($_POST["delivery"]["address1"]) ) $mes .= __('enter the city name', 'usces') . "<br />"; if ( WCUtils::is_blank($_POST["delivery"]["address2"]) ) $mes .= __('enter house numbers', 'usces') . "<br />"; if ( WCUtils::is_blank($_POST["delivery"]["tel"]) ) $mes .= __('enter phone numbers', 'usces') . "<br />"; } if ( !isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !WCUtils::is_zero($_POST['offer']['delivery_method'])) ) { $mes .= __('chose one from delivery method.', 'usces') . "<br />"; } else { $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']); $country = $_SESSION['usces_entry']["delivery"]["country"]; $local_country = usces_get_base_country(); if($country == $local_country) { if($this->options['delivery_method'][$d_method_index]['intl'] == 1) { $mes .= __('Delivery method is incorrect. Can not specify an international flight.', 'usces') . "<br />"; } } else { if( WCUtils::is_zero($this->options['delivery_method'][$d_method_index]['intl']) ) { $mes .= __('Delivery method is incorrect. Specify the international flights.', 'usces') . "<br />"; } } } if ( !isset($_POST['offer']['payment_name']) ){ $mes .= __('chose one from payment options.', 'usces') . "<br />"; }else{ $payments = $this->getPayments($_POST['offer']['payment_name']); if('COD' == $payments['settlement']){ $total_items_price = $this->get_total_price(); $usces_entries = $this->cart->get_entry(); $materials = array( 'total_items_price' => $usces_entries['order']['total_items_price'], 'discount' => $usces_entries['order']['discount'], 'shipping_charge' => $usces_entries['order']['shipping_charge'], 'cod_fee' => $usces_entries['order']['cod_fee'], 'use_point' => ( isset($usces_entries['order']['use_point']) ) ? $usces_entries['order']['use_point'] : 0, ); $tax = $this->getTax( $total_items_price, $materials ); $total_items_price = $total_items_price + $tax; $cod_limit_amount = ( isset($this->options['cod_limit_amount']) && 0 < (int)$this->options['cod_limit_amount'] ) ? $this->options['cod_limit_amount'] : 0; if( 0 < $cod_limit_amount && $total_items_price > $cod_limit_amount ) $mes .= sprintf(__('A total products amount of money surpasses the upper limit(%s) that I can purchase in C.O.D.', 'usces'), usces_crform($this->options['cod_limit_amount'], true, false, 'return')) . "<br />"; } } if( isset($d_method_index) && isset($payments) ) { if($this->options['delivery_method'][$d_method_index]['nocod'] == 1) { if('COD' == $payments['settlement']) $mes .= __('COD is not available.', 'usces') . "<br />"; } } $mes = apply_filters('usces_filter_delivery_check', $mes); return $mes; }
回答2件
あなたの回答
tips
プレビュー