ホームページ  >  記事  >  バックエンド開発  >  PHP は注文の欠落を防ぐために Zen-cart の注文と支払いプロセスを変更します

PHP は注文の欠落を防ぐために Zen-cart の注文と支払いプロセスを変更します

高洛峰
高洛峰オリジナル
2017-01-05 11:26:081595ブラウズ

zen-cartを利用したことのある方はご存知かと思いますが、zen-cartでの注文手順は以下の通りです([]内の表現は不要です):

1. ショッピングカート

2. 【配送方法】

3.お支払い方法

4. 注文確認(確認)

5. [第三者ウェブサイトでの支払い]

6. 注文処理(チェックアウトプロセス) - このステップ ショッピングカート内の情報が書き込まれるため、より重要です。ご注文はこちら

7. 注文成功(チェックアウト成功)

通常の状況ではこのプロセスに問題はありません。ただし、ステップ 5 からステップ 6 までのプロセスでは、ユーザーが支払いが成功したと考えて Web ページを直接閉じたり、ネットワーク上の理由によりユーザーが正常に checkout_process ページにジャンプできない可能性があります。注文を正常に作成できないため、これは非常に深刻です。

上記の分析に基づいて、私たちはプロセスを少し変更したいと考えています。つまり、注文は支払い前に作成されており、たとえ支払いがサードパーティの支払い Web サイトからジャンプバックできなくても、ユーザーが正常に支払いに失敗した場合、バックグラウンドで注文は行われません。変更されたブループリントは基本的に次のとおりです:

1. checkour_confirmation ページで注文を確認した後、直接処理して checkour_success ページに入り、そこで支払いページに入ることができます。下の図に示すように:

php 修改zen-cart下单和付款流程以防止漏单

2. 顧客がその時点で支払いを怠った場合は、独自のバックエンドに入って過去の注文の支払いを行うこともできます。下の図に示すように:

php 修改zen-cart下单和付款流程以防止漏单

上記の関数を実装する方法を段階的に見てみましょう。

1. まず、既存の支払いモジュールを変換する必要があります。支払い用のページ URL を表すフィールド paynow_action_url を支払いメソッド クラスに追加する必要があります。さらに、支払いフォームのパラメータ隠しフィールド コードを取得するために関数 paynow_button($order_id) を追加する必要があります。
paynow_action_url フィールドを追加するには、支払いクラスのコンストラクターの最後に次のコードを追加してください:

if ( (zen_not_null($module)) && (in_array($module.'.php', $this->modules)) && (isset($GLOBALS[$module]->paynow_action_url)) ) { 
$this->paynow_action_url = $GLOBALS[$module]->paynow_action_url; 
}

paynow_button($order_id) 関数を追加するには、支払いクラスの最後の関数の後に次のコードを追加してください。

function paynow_button($order_id){ 
if (is_array($this->modules)) { 
if (is_object($GLOBALS[$this->selected_module])) { 
return $GLOBALS[$this->selected_module]->paynow_button($order_id); 
} 
} 
}

2. PayPal 支払い方法を例として、その実装方法を説明します。 paypal の元のコードを破壊しないように、paypal.php ファイルのコピーを作成し、paypalsimple.php という名前を付け、内部のコードに適切な変更を加えます。コードは以下のとおりです。ここでは、form_action_url の指定が削除され、paynow_action_url が指定されていることがわかります。これは、ユーザーが「注文の確認」をクリックした後に直接 checkout_process に入ってほしいためです。そのため、form_action_url が指定されていない場合は、注文を確認するためのフォームは checkout_process ページに直接送信され、paynow_action_url は前の form_action_url の値です。 paynow_button 関数の実装も非常に簡単です。ここでは、元の process_button() 関数の内容を切り取っているだけですが、グローバル $order 変数を使用せず、$order = new order($order_id) を使用して再実行します。過去の注文で今すぐ支払うボタンを表示する準備として構築されたオブジェクト。
paypalsimple.php

<?php 
/** 
* @package paypalsimple payment module 
* @copyright Copyright 2003-2006 Zen Cart Development Team 
* @copyright Portions Copyright 2003 osCommerce 
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 
* @version $Id: paypalsimple.php 4960 2009-12-29 11:46:46Z gary $ 
*/ 
// ensure dependencies are loaded 
include_once((IS_ADMIN_FLAG === true ? DIR_FS_CATALOG_MODULES : DIR_WS_MODULES) . &#39;payment/paypal/paypal_functions.php&#39;); 
class paypalsimple { 
var $code, $title, $description, $enabled; 
// class constructor 
function paypalsimple() { 
global $order; 
$this->code = &#39;paypalsimple&#39;; 
$this->title = MODULE_PAYMENT_PAYPAL_SIMPLE_TEXT_TITLE; 
if(IS_ADMIN_FLAG === true){ 
$this->title = MODULE_PAYMENT_PAYPAL_SIMPLE_TEXT_ADMIN_TITLE; 
} 
$this->description = MODULE_PAYMENT_PAYPAL_SIMPLE_TEXT_DESCRIPTION; 
$this->sort_order = MODULE_PAYMENT_PAYPAL_SIMPLE_SORT_ORDER; 
$this->enabled = ((MODULE_PAYMENT_PAYPAL_SIMPLE_STATUS == &#39;True&#39;) ? true : false); 
if ((int)MODULE_PAYMENT_PAYPAL_SIMPLE_ORDER_STATUS_ID > 0) { 
$this->order_status = MODULE_PAYMENT_PAYPAL_SIMPLE_ORDER_STATUS_ID; 
} 
$this->paynow_action_url = &#39;https://&#39; . MODULE_PAYMENT_PAYPAL_SIMPLE_HANDLER; 
if (is_object($order)) $this->update_status(); 
} 
// class methods 
function update_status() { 
global $order, $db; 
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYPAL_SIMPLE_ZONE > 0) ) { 
$check_flag = false; 
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = &#39;" . MODULE_PAYMENT_PAYPAL_SIMPLE_ZONE . "&#39; and zone_country_id = &#39;" . $order->billing[&#39;country&#39;][&#39;id&#39;] . "&#39; order by zone_id"); 
while (!$check->EOF) { 
if ($check->fields[&#39;zone_id&#39;] < 1) { 
$check_flag = true; 
break; 
} elseif ($check->fields[&#39;zone_id&#39;] == $order->billing[&#39;zone_id&#39;]) { 
$check_flag = true; 
break; 
} 
$check->MoveNext(); 
} 
if ($check_flag == false) { 
$this->enabled = false; 
} 
} 
} 
function javascript_validation() { 
return false; 
} 
function selection() { 
$text = MODULE_PAYMENT_SIMPLE_PAYPAL_TEXT_CATALOG_LOGO.&#39;  &#39;.MODULE_PAYMENT_PAYPAL_SIMPLE_TEXT_TITLE . &#39;<br/><br/>    <span class="smallText">&#39; . MODULE_PAYMENT_PAYPAL_SIMPLE_ACCEPTANCE_MARK_TEXT . &#39;</span><br/><br/>&#39;; 
return array(&#39;id&#39; => $this->code, 
&#39;module&#39; => $text 
); 
} 
function pre_confirmation_check() { 
return false; 
} 
function confirmation() { 
return false; 
} 
function process_button() { 
return false; 
} 
function before_process() { 
return false; 
} 
function after_process() { 
return false; 
} 
function get_error() { 
return false; 
} 
function check() { 
global $db; 
if (!isset($this->_check)) { 
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_STATUS&#39;"); 
$this->_check = $check_query->RecordCount(); 
} 
return $this->_check; 
} 
function install() { 
global $db; 
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values (&#39;Enable PayPal-Simple Module&#39;, &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_STATUS&#39;, &#39;True&#39;, &#39;Do you want to accept PayPal-Simple payments?&#39;, &#39;6&#39;, &#39;0&#39;, &#39;zen_cfg_select_option(array(\&#39;True\&#39;, \&#39;False\&#39;), &#39;, now())"); 
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values (&#39;Sort order of display.&#39;, &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_SORT_ORDER&#39;, &#39;0&#39;, &#39;Sort order of display. Lowest is displayed first.&#39;, &#39;6&#39;, &#39;8&#39;, now())"); 
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values (&#39;Payment Zone&#39;, &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_ZONE&#39;, &#39;0&#39;, &#39;If a zone is selected, only enable this payment method for that zone.&#39;, &#39;6&#39;, &#39;2&#39;, &#39;zen_get_zone_class_title&#39;, &#39;zen_cfg_pull_down_zone_classes(&#39;, now())"); 
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values (&#39;Set Order Status&#39;, &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_ORDER_STATUS_ID&#39;, &#39;0&#39;, &#39;Set the status of orders made with this payment module to this value&#39;, &#39;6&#39;, &#39;0&#39;, &#39;zen_cfg_pull_down_order_statuses(&#39;, &#39;zen_get_order_status_name&#39;, now())"); 
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values (&#39;Mode for PayPal web services<br /><br />Default:<br /><code>www.paypal.com/cgi-bin/webscr</code><br />or<br /><code>www.paypal.com/us/cgi-bin/webscr</code><br />or for the UK,<br /><code>www.paypal.com/uk/cgi-bin/webscr</code>&#39;, &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_HANDLER&#39;, &#39;www.paypal.com/cgi-bin/webscr&#39;, &#39;Choose the URL for PayPal live processing&#39;, &#39;6&#39;, &#39;73&#39;, &#39;&#39;, now())"); 
} 
function remove() { 
global $db; 
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in (&#39;" . implode("&#39;, &#39;", $this->keys()) . "&#39;)"); 
} 
function keys() { 
return array(&#39;MODULE_PAYMENT_PAYPAL_SIMPLE_STATUS&#39;,&#39;MODULE_PAYMENT_PAYPAL_SIMPLE_SORT_ORDER&#39;,&#39;MODULE_PAYMENT_PAYPAL_SIMPLE_ZONE&#39;,&#39;MODULE_PAYMENT_PAYPAL_SIMPLE_ORDER_STATUS_ID&#39;, &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_HANDLER&#39;); 
} 
function paynow_button($order_id){ 
global $db, $order, $currencies, $currency; 
require_once(DIR_WS_CLASSES . &#39;order.php&#39;); 
$order = new order($order_id); 
$options = array(); 
$optionsCore = array(); 
$optionsPhone = array(); 
$optionsShip = array(); 
$optionsLineItems = array(); 
$optionsAggregate = array(); 
$optionsTrans = array(); 
$buttonArray = array(); 
$this->totalsum = $order->info[&#39;total&#39;]; 
// save the session stuff permanently in case paypal loses the session 
$_SESSION[&#39;ppipn_key_to_remove&#39;] = session_id(); 
$db->Execute("delete from " . TABLE_PAYPAL_SESSION . " where session_id = &#39;" . zen_db_input($_SESSION[&#39;ppipn_key_to_remove&#39;]) . "&#39;"); 
$sql = "insert into " . TABLE_PAYPAL_SESSION . " (session_id, saved_session, expiry) values ( 
&#39;" . zen_db_input($_SESSION[&#39;ppipn_key_to_remove&#39;]) . "&#39;, 
&#39;" . base64_encode(serialize($_SESSION)) . "&#39;, 
&#39;" . (time() + (1*60*60*24*2)) . "&#39;)"; 
$db->Execute($sql); 
$my_currency = select_pp_currency(); 
$this->transaction_currency = $my_currency; 
$this->transaction_amount = ($this->totalsum * $currencies->get_value($my_currency)); 
$telephone = preg_replace(&#39;/\D/&#39;, &#39;&#39;, $order->customer[&#39;telephone&#39;]); 
if ($telephone != &#39;&#39;) { 
$optionsPhone[&#39;H_PhoneNumber&#39;] = $telephone; 
if (in_array($order->customer[&#39;country&#39;][&#39;iso_code_2&#39;], array(&#39;US&#39;,&#39;CA&#39;))) { 
$optionsPhone[&#39;night_phone_a&#39;] = substr($telephone,0,3); 
$optionsPhone[&#39;night_phone_b&#39;] = substr($telephone,3,3); 
$optionsPhone[&#39;night_phone_c&#39;] = substr($telephone,6,4); 
$optionsPhone[&#39;day_phone_a&#39;] = substr($telephone,0,3); 
$optionsPhone[&#39;day_phone_b&#39;] = substr($telephone,3,3); 
$optionsPhone[&#39;day_phone_c&#39;] = substr($telephone,6,4); 
} else { 
$optionsPhone[&#39;night_phone_b&#39;] = $telephone; 
$optionsPhone[&#39;day_phone_b&#39;] = $telephone; 
} 
} 
$optionsCore = array( 
&#39;charset&#39; => CHARSET, 
&#39;lc&#39; => $order->customer[&#39;country&#39;][&#39;iso_code_2&#39;], 
&#39;page_style&#39; => MODULE_PAYMENT_PAYPAL_PAGE_STYLE, 
&#39;custom&#39; => zen_session_name() . &#39;=&#39; . zen_session_id(), 
&#39;business&#39; => MODULE_PAYMENT_PAYPAL_BUSINESS_ID, 
&#39;return&#39; => zen_href_link(FILENAME_PAY_SUCCESS, &#39;referer=paypal&#39;, &#39;SSL&#39;), 
&#39;cancel_return&#39; => zen_href_link(FILENAME_PAY_FAILED, &#39;&#39;, &#39;SSL&#39;), 
&#39;shopping_url&#39; => zen_href_link(FILENAME_SHOPPING_CART, &#39;&#39;, &#39;SSL&#39;), 
&#39;notify_url&#39; => zen_href_link(&#39;ipn_main_handler.php&#39;, &#39;&#39;, &#39;SSL&#39;,false,false,true), 
&#39;redirect_cmd&#39; => &#39;_xclick&#39;, 
&#39;rm&#39; => 2, 
&#39;bn&#39; => &#39;zencart&#39;, 
&#39;mrb&#39; => &#39;R-6C7952342H795591R&#39;, 
&#39;pal&#39; => &#39;9E82WJBKKGPLQ&#39;, 
); 
$optionsCust = array( 
&#39;first_name&#39; => replace_accents($order->customer[&#39;firstname&#39;]), 
&#39;last_name&#39; => replace_accents($order->customer[&#39;lastname&#39;]), 
&#39;address1&#39; => replace_accents($order->customer[&#39;street_address&#39;]), 
&#39;city&#39; => replace_accents($order->customer[&#39;city&#39;]), 
&#39;state&#39; => zen_get_zone_code($order->customer[&#39;country&#39;][&#39;id&#39;], $order->customer[&#39;zone_id&#39;], $order->customer[&#39;zone_id&#39;]), 
&#39;zip&#39; => $order->customer[&#39;postcode&#39;], 
&#39;country&#39; => $order->customer[&#39;country&#39;][&#39;iso_code_2&#39;], 
&#39;email&#39; => $order->customer[&#39;email_address&#39;], 
); 
if ($order->customer[&#39;suburb&#39;] != &#39;&#39;) $optionsCust[&#39;address2&#39;] = $order->customer[&#39;suburb&#39;]; 
if (MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED == 2) $optionsCust = array( 
&#39;address_name&#39; => replace_accents($order->customer[&#39;firstname&#39;] . &#39; &#39; . $order->customer[&#39;lastname&#39;]), 
&#39;address_street&#39; => replace_accents($order->customer[&#39;street_address&#39;]), 
&#39;address_city&#39; => replace_accents($order->customer[&#39;city&#39;]), 
&#39;address_state&#39; => zen_get_zone_code($order->customer[&#39;country&#39;][&#39;id&#39;], $order->customer[&#39;zone_id&#39;], $order->customer[&#39;zone_id&#39;]), 
&#39;address_zip&#39; => $order->customer[&#39;postcode&#39;], 
&#39;address_country&#39; => $order->customer[&#39;country&#39;][&#39;title&#39;], 
&#39;address_country_code&#39; => $order->customer[&#39;country&#39;][&#39;iso_code_2&#39;], 
&#39;payer_email&#39; => $order->customer[&#39;email_address&#39;], 
); 
$optionsShip = array( 
//&#39;address_override&#39; => MODULE_PAYMENT_PAYPAL_ADDRESS_OVERRIDE, 
&#39;no_shipping&#39; => MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED, 
); 
if (MODULE_PAYMENT_PAYPAL_DETAILED_CART == &#39;Yes&#39;) $optionsLineItems = ipn_getLineItemDetails(); 
if (sizeof($optionsLineItems) > 0) { 
$optionsLineItems[&#39;cmd&#39;] = &#39;_cart&#39;; 
// $optionsLineItems[&#39;num_cart_items&#39;] = sizeof($order->products); 
if (isset($optionsLineItems[&#39;shipping&#39;])) { 
$optionsLineItems[&#39;shipping_1&#39;] = $optionsLineItems[&#39;shipping&#39;]; 
unset($optionsLineItems[&#39;shipping&#39;]); 
} 
if (isset($optionsLineItems[&#39;handling&#39;])) { 
$optionsLineItems[&#39;handling_1&#39;] = $optionsLineItems[&#39;handling&#39;]; 
unset($optionsLineItems[&#39;handling&#39;]); 
} 
unset($optionsLineItems[&#39;subtotal&#39;]); 
// if line-item details couldn&#39;t be kept due to calculation mismatches or discounts etc, default to aggregate mode 
if (!isset($optionsLineItems[&#39;item_name_1&#39;])) $optionsLineItems = array(); 
//if ($optionsLineItems[&#39;amount&#39;] != $this->transaction_amount) $optionsLineItems = array(); 
ipn_debug_email(&#39;Line Item Details (if blank, this means there was a data mismatch, and thus bypassed): &#39; . "\n" . print_r($optionsLineItems, true)); 
} 
$products_name_display = ""; 
/* 
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { 
if(i > 0) { 
$products_name_display.= &#39;, &#39;; 
} 
$products_name_display.= $order->products[$i][&#39;name&#39;]. &#39;(&#39;. $order->products[$i][&#39;qty&#39;] .&#39;,&#39;.$order->products[$i][&#39;dhisys_web_order_number&#39;].&#39;)&#39;; 
}*/ 
$optionsAggregate = array( 
&#39;cmd&#39; => &#39;_ext-enter&#39;, 
&#39;item_name&#39; => $products_name_display, 
&#39;item_number&#39; => $order_id, 
&#39;num_cart_items&#39; => sizeof($order->products), 
&#39;amount&#39; => number_format($this->transaction_amount, $currencies->get_decimal_places($my_currency)), 
&#39;shipping&#39; => &#39;0.00&#39;, 
); 
if (MODULE_PAYMENT_PAYPAL_TAX_OVERRIDE == &#39;true&#39;) $optionsAggregate[&#39;tax&#39;] = &#39;0.00&#39;; 
if (MODULE_PAYMENT_PAYPAL_TAX_OVERRIDE == &#39;true&#39;) $optionsAggregate[&#39;tax_cart&#39;] = &#39;0.00&#39;; 
$optionsTrans = array( 
&#39;upload&#39; => (int)(sizeof($order->products) > 0), 
&#39;currency_code&#39; => $my_currency, 
// &#39;paypal_order_id&#39; => $paypal_order_id, 
//&#39;no_note&#39; => &#39;1&#39;, 
//&#39;invoice&#39; => &#39;&#39;, 
); 
// if line-item info is invalid, use aggregate: 
if (sizeof($optionsLineItems) > 0) $optionsAggregate = $optionsLineItems; 
// prepare submission 
$options = array_merge($optionsCore, $optionsCust, $optionsPhone, $optionsShip, $optionsTrans, $optionsAggregate); 
ipn_debug_email(&#39;Keys for submission: &#39; . print_r($options, true)); 
if(sizeof($order->products) > 0){ 
$options[&#39;cmd&#39;] = &#39;_cart&#39;; 
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { 
$options[&#39;item_name_&#39;. (string)($i+1)] = $order->products[$i][&#39;name&#39;]; 
$options[&#39;item_number_&#39;. (string)($i+1)] = $order->products[$i][&#39;dhisys_web_order_number&#39;]; 
$options[&#39;amount_&#39;. (string)($i+1)] = number_format((float)$order->products[$i][&#39;final_price&#39;],2); 
$options[&#39;quantity_&#39;. (string)($i+1)] = $order->products[$i][&#39;qty&#39;]; 
} 
} 
// build the button fields 
foreach ($options as $name => $value) { 
// remove quotation marks 
$value = str_replace(&#39;"&#39;, &#39;&#39;, $value); 
// check for invalid chars 
if (preg_match(&#39;/[^a-zA-Z_0-9]/&#39;, $name)) { 
ipn_debug_email(&#39;datacheck - ABORTING - preg_match found invalid submission key: &#39; . $name . &#39; (&#39; . $value . &#39;)&#39;); 
break; 
} 
// do we need special handling for & and = symbols? 
//if (strpos($value, &#39;&&#39;) !== false || strpos($value, &#39;=&#39;) !== false) $value = urlencode($value); 
$buttonArray[] = zen_draw_hidden_field($name, $value); 
} 
$_SESSION[&#39;paypal_transaction_info&#39;] = array($this->transaction_amount, $this->transaction_currency); 
$process_button_string = implode("\n", $buttonArray) . "\n"; 
return $process_button_string; 
} 
} 
?>

3. checkout_success ページに [今すぐ支払う] ボタンを表示します。ファイル「includes/modules/pages/checkout_success/header.php」を開き、ファイルの最後に次のコードを追加します (zen-cart のノーティファイア/オブザーバー モードをマスターしていて、zen-cart の機能を中断したくない場合)カート コア コード その場合、NOTIFY_HEADER_END_CHECKOUT_SUCCESS をリッスンする観察クラスを作成することもできます。

require_once(DIR_WS_CLASSES . &#39;order.php&#39;); 
require_once(DIR_WS_CLASSES . &#39;payment.php&#39;); 
$payment_modules = new payment($orders->fields[&#39;payment_module_code&#39;]);

「includes/modules/templates/template_default/templates/tpl_checkout_success_default.php」ファイルを開き、ここでは注文のステータスのみを判断します。注文は未払いです ボタンはステータスが

の場合にのみ表示されます
<div id="pay_now"> 
<?php 
//&& $orders->fields[&#39;orders_status&#39;] == &#39;1&#39; 
if(isset($payment_modules->paynow_action_url) && $payment_modules->paynow_action_url != &#39;&#39;&& $orders->fields[&#39;orders_status&#39;] == &#39;1&#39;){ 
echo(&#39;<fieldset id="csNotifications">&#39;); 
echo(&#39;<legend>&#39;.TEXT_PAYNOW.&#39;</legend>&#39;); 
echo zen_draw_form(&#39;checkout_paynow&#39;, $payment_modules->paynow_action_url, &#39;post&#39;, &#39;id="checkout_confirmation" onsubmit="submitonce();"&#39;); 
$selection = $payment_modules->selection(); 
echo(&#39;<div class="buttonRow payment_method">&#39;.$selection[0][&#39;module&#39;].&#39;</div>&#39;); 
echo(&#39;<div class="buttonRow forward paynow">&#39;); 
if (is_array($payment_modules->modules)) { 
echo $payment_modules->paynow_button($orders_id); 
} 
echo(zen_image_submit(BUTTON_IMAGE_PAYNOW, BUTTON_IMAGE_PAYNOW_ALT, &#39;name="btn_paynow" id="btn_paynow"&#39;)); 
echo(&#39;</div>&#39;); 
echo(&#39;</form>&#39;); 
echo(&#39;</fieldset>&#39;); 
} 
?> 
</div>

4. 在历史订单中显示pay now按钮。需要显示pay now按钮的页面有三个:account, account_history,account_history_info,这里的实现和checkout_success页面的实现大同小异,只是传给$payment_modules的函数paynow_button的参数不一样而已,这里就不再赘述。 
总结: 
经过上面的修改,我们的流程如下: 
1. 购物车(shopping cart) 
2. [货运方式(delivery method)] 
3. 支付方式(payment method) 
4. 订单确认(confirmation) 
5. 订单处理(checkout process) 
6. 下单成功(checkout success) 
7. [第三方网站支付] 
因为从订单确认到订单处理,都是在我们自己的网站完成的,并且进入支付网站之前,订单已经存在了,这样就不会出现掉单的情况了。 

更多php 修改zen-cart下单和付款流程以防止漏单相关文章请关注PHP中文网!

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。