Add Netsuite Sales order items - web-services

I am getting this type of error:
=> i am getting error in the integration of the netsuite.
In sales order add the items in the netsuite so there are some error is define in above section my code is below please see the code add how to solve this problem.
[code] => USER_ERROR
[message] => You must enter at least one line item for this transaction.
[type] => ERRORi am gatting this type of error please help me
[code] => USER_ERROR
[message] => You must enter at least one line item for this transaction.
[type] => ERROR
my code is
include('NetSuiteService.php');
$service = new NetSuiteService();
if($order_items->netsuitid > 0){
$internal_Id = $order_items->netsuitid;
$emailCustomer = $order_items->user_email;
}
else{
$customer_Info = $order->get_customer_info($order->user_id);
$customer_information = array();
foreach($customer_Info as $customer_key => $customer_value){
if($customer_value->meta_key == 'first_name'){
$customer_information['first_name'] = $customer_value->meta_value;
}
if($customer_value->meta_key == 'last_name'){
$customer_information['last_name'] = $customer_value->meta_value;
}
}
$customer_information['email'] = $customer_Info->user_email;
//Add customer into net suit integration
$service = new NetSuiteService();
$customer = new Customer();
$customer->lastName = $customer_information['last_name'];
$customer->firstName = $customer_information['first_name'];
$customer->companyName = 'Company Name';
$customer->phone = '2222222222';
$customer->email = $customer_information['email'];
$emailCustomer = $customer_information['email'];
$request = new AddRequest();
$request->record = $customer;
$addResponse = $service->add($request);
if (!$addResponse->writeResponse->status->isSuccess) {
echo "You are already Registered with Netsuit.";
}
else {
$internal_Id = $addResponse->writeResponse->baseRef->internalId;
$order->insert_Customer($internal_Id,$order->user_id);
}
//End customer into net suit integration
}
//Add Product Information
/*$items = array();
foreach ( $order_items as $item_id => $item ) {
$itemRef = new nsRecordRef(array('internalId'=>$internal_Id));
$qty = $item['qty'];
if($item['type'] == 'line_item'){
$salesOrderItemFieldArray = array(
"item" => $itemRef,
"quantity" => $qty
);
}
if($item['type'] == 'fee'){
$salesOrderItemFieldArray = array(
"item" => $itemRef,
"quantity" => $qty
);
}
$SalesOrderItem->setFields($salesOrderItemFieldArray);
$items[] = $SalesOrderItem;
}
$salesOrderItemList = new nsComplexObject("SalesOrderItemList");
$salesOrderItemList->setFields(array(
"item" => $items
));
$salesOrderFields = array(
"orderStatus" => $order->status,
"entity" => '',
"getAuth" => true,
"shippingCost" => $order->order_shipping,
"shipMethod" => $order->payment_method,
"toBeEmailed" => true,
"email" => $emailCustomer,
"itemList" => $salesOrderItemList
);*/
$so = new SalesOrder();
//created Date
//$so->createdDate = $order->order_date;
//entity
$so->entity = new RecordRef();
$so->entity->internalId = $internal_Id;
$so->entity->name = $order->order_custom_fields['_billing_company'][0];
//Transaction Id
//$so->tranId = $order->order_custom_fields['Transaction ID'][0];
//Transaction Paid Date
//$so->tranDate = $order->order_custom_fields['_paid_date'][0];
//Source
$so->source = 'littlecrate';
//Created From
$so->createdFrom = 'littlecrate.com';
//Currency Name
require_once('geoplugin.class.php');
$geoplugin = new geoPlugin();
$geoplugin->currency = $order->order_custom_fields['_order_currency'];
$so->currencyName = $geoplugin->countryName;
$so->currency = $order->order_custom_fields['_order_currency'][0];
//Discount
$so->discountRate = $order->order_custom_fields['_order_discount'][0];
//Tax
$so->taxRate = $order->order_custom_fields['_order_tax'][0];
//email
$so->email = $order->billing_email;
//Status
//$so->orderStatus = $order->status;
//Billing Address
$so->billAddressList = array(
'billFirstname' => $order->order_custom_fields['_billing_first_name'][0],
'lastname' => $order->order_custom_fields['_billing_last_name'][0],
'billAddressee' => $order->order_custom_fields['_billing_address_1'][0],
'billAddr1' => $order->order_custom_fields['_billing_address_2'][0],
'billCountry' => $order->order_custom_fields['_billing_country'][0],
'billState' => $order->order_custom_fields['_billing_state'][0],
'billZip' => $order->order_custom_fields['_billing_postcode'][0],
'billPhone' => $order->order_custom_fields['_billing_phone'][0],
'billEmail' => $order->order_custom_fields['_billing_email'][0]);
//Shipping Address
$so->shipAddressList = array(
'shipFirstname' => $order->order_custom_fields['_shipping_first_name'][0],
'shipLastname' => $order->order_custom_fields['_shipping_last_name'][0],
'shipAddressee' => $order->order_custom_fields['_shipping_address_1'][0],
'shipAddr1' => $order->order_custom_fields['_shipping_address_2'][0],
'shipCity' => $order->order_custom_fields['_shipping_city'][0],
'shipState' => $order->order_custom_fields['_shipping_state'][0],
'shipZip' => $order->order_custom_fields['_shipping_postcode'][0],
'shiplPhone' => $order->order_custom_fields['_billing_phone'][0],
'shipEmail' => $order->order_custom_fields['_billing_email'][0]);
//Ship Date
//$so->shipDate = $order->order_custom_fields['Transaction ID'][0];
//Shipping Method
$so->shipMethod = $order->shipping_method;
//Shipping Charges
$so->shippingCost = $order->order_shipping;
//Shipping Tax Rate
$so->shippingTax1Rate = $order->order_shipping_tax;
//Payment Method
$so->paymentMethod = $order->payment_method;
//Sub Total
//$so->subTotal = $order->order_total;
//Discount Total(Cart Total)
//$so->discountTotal = $order->cart_discount;
//Tax Total
//$so->taxTotal = $order->order_tax;
//Total
//$so->total = $order->order_total;
//Product Listing
$arrItemsList = array();
$i = 0;
foreach($order_items_product as $keyProduct =>$valueProduct){
if($valueProduct['type'] == 'line_item'){
//$arrItemsList[$i]['item']['internalId'] = $valueProduct['product_id'];
//$arrItemsList[$i]['item']['externalId'] = $keyProduct;
$arrItemsList[$i]['item']['name'] = $valueProduct['name'];
$arrItemsList[$i]['item']['quantity'] = $valueProduct['qty'];
$arrItemsList[$i]['item']['description'] = $valueProduct['type'];
$arrItemsList[$i]['item']['amount'] = $valueProduct['line_total'];
}
if($valueProduct['type'] == 'fee'){
//$arrItemsList[$i]['item']['internalId'] = $valueProduct['product_id'];
//$arrItemsList[$i]['item']['externalId'] = $keyProduct;
$arrItemsList[$i]['item']['name'] = $valueProduct['name'];
$arrItemsList[$i]['item']['quantity'] = $valueProduct['qty'];
$arrItemsList[$i]['item']['description'] = $valueProduct['type'];
$arrItemsList[$i]['item']['amount'] = $valueProduct['line_total'];
}
$i++;
}
//print_r($arrItemsList);
$so->itemList->item = $arrItemsList;
/*$so->itemList = new SalesOrderItemList();
$soi = new SalesOrderItem();
$soi->item = new RecordRef();
$soi->item->internalId = 15;
$soi->quantity = 3;
$soi->price = new RecordRef();
$soi->price->internalId = $id;
$soi->amount = 55.3;
$so->itemList->item = array($soi);*/
$request = new AddRequest();
$request->record = $so;
//print_r($request);
$addResponse = $service->add($request);
print_r($addResponse);
exit;
if (!$addResponse->writeResponse->status->isSuccess) {
echo "ADD ERROR";
} else {
echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId;
}
+

I Complited Using The Help Of Saqib,
http://stackoverflow.com/users/810555/saqib
He is The Great Developer And Regarding Netsuite Information Please Contact To Saqib Thanks Man U Just Do It.
<?php
$order_date = date('Y-m-d H:i:s');
// create array of fields
$itemArr = array();
$i = 0;
foreach($order_items_product as $keyProduct =>$valueProduct){
//if you not have internal id of item in netsuuite then please add the item in the netsuite and try.
$netsuiteItemId = 'Your Item Internal id Which is in the Netsuite Item';
$itemArr[$i]['item']['internalId'] = $netsuiteItemId;
$itemArr[$i]['quantity'] = $valueProduct['qty'];
$i++;
}
if (!define('LF', "\n")) {
define('LF', "\n");
}
/* for use in formatting custom addresses since NetSuite converts to <br> */
//Billing Address Information
/* this example has the customer address info in a db record, just pulled into $row */
$billAddress = stripslashes($order->order_custom_fields['_billing_first_name'][0]) . ' ' . $order->order_custom_fields['_billing_last_name'][0] . LF;
$billAddress .= stripslashes($order->order_custom_fields['_billing_address_1'][0]).LF;
$billAddress .= stripslashes($order->order_custom_fields['_billing_address_2'][0]).LF;
$billAddress .= stripslashes($order->order_custom_fields['_billing_country'][0]).LF;
$billAddress .= stripslashes($order->order_custom_fields['_billing_state'][0]) . ' - ' . $order->order_custom_fields['_billing_postcode'][0] . ', ' . LF;
$billAddress .= $order->order_custom_fields['_billing_phone'][0] . ', ' . $order->order_custom_fields['_billing_email'][0];
//Shipping Address Information
$shipAddress = stripslashes($order->order_custom_fields['_shipping_first_name'][0]) . ' ' . $order->order_custom_fields['_shipping_last_name'][0] . LF;
$shipAddress .= stripslashes($order->order_custom_fields['_shipping_address_1'][0]).LF;
$shipAddress .= stripslashes($order->order_custom_fields['_shipping_address_2'][0]).LF;
$shipAddress .= stripslashes($order->order_custom_fields['_shipping_city'][0]).LF;
$shipAddress .= stripslashes($order->order_custom_fields['_shipping_state'][0]) . ', ' . $order->order_custom_fields['_shipping_postcode'][0] . ', ' . LF;
$shipAddress .= $order->order_custom_fields['_billing_phone'][0] .', '. $order->order_custom_fields['_billing_email'][0];
$purchaseOrderFields = array (
'entity' => array ('internalId' => $internal_Id, 'type' => 'customer'),
'shippingCost' => $order->order_shipping,
'shipMethod' => $order->payment_method,
'toBeEmailed' => true,
//'tranId' => $order->order_custom_fields['Transaction ID'][0],
//'tranDate' => date('Y-m-d H:i:s'),
'source' => 'littlecrate',
'createdFrom' => 'littlecrate.com',
'discountRate' => $order->order_custom_fields['_order_discount'][0],
'taxRate' => $order->order_custom_fields['_order_tax'][0],
'email' => $order->billing_email,
//'shipDate' => date('Y-m-d H:i:s'),
'shipMethod' => $order->shipping_method,
'shippingCost' => $order->order_shipping,
'shippingTax1Rate' => $order->order_shipping_tax,
'paymentMethod' => $order->payment_method,
//'taxTotal' => $order->order_tax,
//'total' => $order->order_total,
'billAddress' => $billAddress,
'shipAddress' => $shipAddress,
'itemList' => array (
'item' => $itemArr
)
);
$salesOrder = new nsComplexObject('SalesOrder');
$salesOrder ->setFields($purchaseOrderFields);
$addResponse = $myNSclient->add($salesOrder );
if (!$addResponse->isSuccess) {
echo "Order Information is Not Inserted Into The Netsuite. Please Contact to Administration.";
exit;
}
?>

You item List object doesn't seem in correct format. Your code should look like this
$itemArr = array();
foreach($order_items_product as $keyProduct =>$valueProduct){
$item = new SalesOrderItem();
$item->item = $valueProduct['product_id'];
$item->quantity = $valueProduct['qty'];
$itemArr[] = $item;
}
$itemList = new SalesOrderItemList();
$itemList->item = $itemArr;
$so->itemList->item = $itemList;

Related

Rewrite controller file of opencart 2.3 extension to opencart 3.X (twig)

I need your help in how can I change this controller code of opencart 2.3 extension to be compatible for opencart 3.X,
I have changed the tpl files in admin/view/template/extension/payment/ to twig with their parameters
also I changed the 'token=' to user_token in the controller
file path
admin/controller/extension/payment/
<?php
class ControllerExtensionPaymentIcredit extends Controller {
private $error = array();
public function install()
{
$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "iCredit` (
`id_icredit` int(1) NOT NULL AUTO_INCREMENT,
`enabled` varchar(255),
`PaymentMethodDescription` varchar(500) CHARACTER SET utf8,
`title` varchar(255) CHARACTER SET utf8,
`testmode` varchar(1),
`testtoken` varchar(255),
`grouptoken` varchar(500),
`maxpayment` varchar(255),
`creditpayment` varchar(500),
`windowtype` varchar(255),
`height` int(10),
`width` int(10),
`hideitemlist` varchar(1),
`createtoken` varchar(1),
`invoicelang` varchar(500),
`exemptvat` varchar(255),
`redirecturl` varchar(500),
`ipn` varchar(500),
`sortorder` varchar(500),
`date_added` datetime,
PRIMARY KEY (`id_icredit`)
)");
}
public function uninstall()
{
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "iCredit");
}
public function index()
{ // Default function
$this->install();
$this->load->language('extension/payment/icredit'); // Loading the language file of helloworld
$this->document->setTitle($this->language->get('heading_title')); // Set the title of the page to the heading title in the Language file i.e., Hello World
$this->load->model('setting/setting');
$this->load->model('extension/payment/icredit'); // Load the Setting Model (All of the OpenCart Module & General Settings are saved using this Model )
//fwrite($file,$this->validate()." -- validate\r\n");
//fwrite($file,print_r($_POST,TRUE)." -- post\r\n");
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate())
{
if ($this->request->post['icredit_id'] == "")
{
$this->model_setting_setting->editSetting('icredit', $this->request->post);
$check = $this->model_extension_payment_icredit->addicreditsettings($this->request->post);
}
else
{
$this->model_setting_setting->editSetting('icredit', $this->request->post);
$check = $this->model_extension_payment_icredit->editicreditsettings($this->request->post);
}
$this->session->data['success'] = $this->language->get('text_success'); // To display the success text on data save=
if($check == 1)
{
$this->response->redirect($this->url->link('extension/extension', 'token=' . $this->session->data['token'], 'SSL')); // Redirect to the Module Listing
}
}
/*Assign the language data for parsing it to view*/
$data['heading_title'] = $this->language->get('heading_title');
$data['text_edit'] = $this->language->get('text_edit');
$data['text_enabled'] = $this->language->get('text_enabled');
$data['text_content_top'] = $this->language->get('text_content_top');
$data['text_content_bottom'] = $this->language->get('text_content_bottom');
$data['text_column_left'] = $this->language->get('text_column_left');
$data['text_column_right'] = $this->language->get('text_column_right');
$data['text_enabled'] = $this->language->get('text_enabled');
$data['text_paymentdescription'] = $this->language->get('text_paymentdescription');
$data['text_title'] = $this->language->get('text_title');
$data['text_testmode'] = $this->language->get('text_testmode');
$data['text_testgrouptoken'] = $this->language->get('text_testgrouptoken');
$data['text_prodgrouptoken'] = $this->language->get('text_prodgrouptoken');
$data['text_maxpayment'] = $this->language->get('text_maxpayment');
$data['text_creditpayment'] = $this->language->get('text_creditpayment');
$data['text_windowselecttype'] = $this->language->get('text_windowselecttype');
$data['text_optionredirect'] = $this->language->get('text_optionredirect');
$data['text_optionpopup'] = $this->language->get('text_optionpopup');
$data['text_optioniframe'] = $this->language->get('text_optioniframe');
$data['text_height'] = $this->language->get('text_height');
$data['text_width'] = $this->language->get('text_width');
$data['text_hideitemlist'] = $this->language->get('text_hideitemlist');
$data['text_createtoken'] = $this->language->get('text_createtoken');
$data['text_invoicelang'] = $this->language->get('text_invoicelang');
$data['text_english'] = $this->language->get('text_english');
$data['text_hebrew'] = $this->language->get('text_hebrew');
$data['text_billing'] = $this->language->get('text_billing');
$data['text_shipping'] = $this->language->get('text_shipping');
$data['text_billingshipping'] = $this->language->get('text_billingshipping');
$data['text_exemptvat'] = $this->language->get('text_exemptvat');
$data['text_chargevat'] = $this->language->get('text_chargevat');
$data['text_exempt'] = $this->language->get('text_exempt');
$data['text_billing'] = $this->language->get('text_billing');
$data['text_shipping'] = $this->language->get('text_shipping');
$data['text_billingshipping'] = $this->language->get('text_billingshipping');
$data['text_redirecturl'] = $this->language->get('text_redirecturl');
$data['text_sortorder'] = $this->language->get('text_sortorder');
$data['text_ipn'] = $this->language->get('text_ipn');
$data['text_yes'] = $this->language->get('text_yes');
$data['text_no'] = $this->language->get('text_no');
$data['entry_code'] = $this->language->get('entry_code');
$data['entry_layout'] = $this->language->get('entry_layout');
$data['entry_position'] = $this->language->get('entry_position');
$data['entry_status'] = $this->language->get('entry_status');
$data['entry_sort_order'] = $this->language->get('entry_sort_order');
$data['button_save'] = $this->language->get('button_save');
$data['button_cancel'] = $this->language->get('button_cancel');
$data['button_add_module'] = $this->language->get('button_add_module');
$data['button_remove'] = $this->language->get('button_remove');
$data['entry_order_status'] = $this->language->get('entry_order_status');
$data['pending_order_status'] = $this->language->get('pending_order_status');
$data['processing_order_status'] = $this->language->get('processing_order_status');
$this->load->model('localisation/order_status');
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
// return warning if any*/
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['description'])) {
$data['description'] = $this->error['description'];
} else {
$data['description'] = '';
}
/* Making of Breadcrumbs to be displayed on site*/
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => false
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_module'),
'href' => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => ' :: '
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('extension/payment/icredit', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => ' :: '
);
/* End Breadcrumb Block*/
$data['action'] = $this->url->link('extension/payment/icredit', 'token=' . $this->session->data['token'], 'SSL'); // URL to be directed when the save button is pressed
$data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'); // URL to be redirected when cancel button is pressed
/* This block checks, if the hello world text field is set it parses it to view otherwise get the default hello world text field from the database and parse it*/
if (isset($this->request->post['PaymentMethodDescription'])) {
$data['PaymentMethodDescription'] = $this->request->post['PaymentMethodDescription'];
} else {
$data['PaymentMethodDescription'] = $this->config->get('PaymentMethodDescription');
}
if (isset($this->request->post['icredit_complete_order_status_id'])) {
$data['icredit_complete_order_status_id'] = $this->request->post['icredit_complete_order_status_id'];
} else {
$data['icredit_complete_order_status_id'] = $this->config->get('icredit_complete_order_status_id');
}
if (isset($this->request->post['icredit_pending_order_status_id'])) {
$data['icredit_pending_order_status_id'] = $this->request->post['icredit_pending_order_status_id'];
} else {
$data['icredit_pending_order_status_id'] = $this->config->get('icredit_pending_order_status_id');
}
if (isset($this->request->post['icredit_processing_order_status_id'])) {
$data['icredit_processing_order_status_id'] = $this->request->post['icredit_processing_order_status_id'];
} else {
$data['icredit_processing_order_status_id'] = $this->config->get('icredit_processing_order_status_id');
}
/* End Block*/
$data['modules'] = array();
/* This block parses the Module Settings such as Layout, Position,Status & Order Status to the view*/
if (isset($this->request->post['PaymentMethodDescription'])) {
$data['modules'] = $this->request->post['PaymentMethodDescription'];
} elseif ($this->config->get('PaymentMethodDescription')) {
$data['modules'] = $this->config->get('PaymentMethodDescription');
}
/* End Block*/
$this->load->model('design/layout'); // Loading the Design Layout Models
$data['layouts'] = $this->model_design_layout->getLayouts(); // Getting all the Layouts available on system
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$getsettings = $this->model_extension_payment_icredit->addGeticreditsettings();
$data['editdata']=array();
if(isset($getsettings))
{
$data['editdata']['icredit_id'] = $getsettings['id_icredit'];
$data['editdata']['enabled'] = $getsettings['enabled'];
$data['editdata']['PaymentMethodDescription'] = $getsettings['PaymentMethodDescription'];
$data['editdata']['title'] = $getsettings['title'];
$data['editdata']['testmode'] = $getsettings['testmode'];
$data['editdata']['testtoken'] = $getsettings['testtoken'];
$data['editdata']['grouptoken'] = $getsettings['grouptoken'];
$data['editdata']['maxpayment'] = $getsettings['maxpayment'];
$data['editdata']['creditpayment'] = $getsettings['creditpayment'];
$data['editdata']['windowtype'] = $getsettings['windowtype'];
$data['editdata']['height'] = $getsettings['height'];
$data['editdata']['width'] = $getsettings['width'];
$data['editdata']['hideitemlist'] = $getsettings['hideitemlist'];
$data['editdata']['createtoken'] = $getsettings['createtoken'];
$data['editdata']['invoicelang'] = $getsettings['invoicelang'];
$data['editdata']['exemptvat'] = $getsettings['exemptvat'];
$data['editdata']['redirecturl'] = $getsettings['redirecturl'];
$data['editdata']['ipn'] = $getsettings['ipn'];
$data['editdata']['sortorder'] = $getsettings['sortorder'];
}
$data['editdata'] = $data['editdata'];
$this->response->setoutput($this->load->view('extension/payment/icredit.tpl', $data));
}
protected function validate() {
/* Block to check the user permission to manipulate the module*/
if (!$this->user->hasPermission('modify', 'extension/payment/icredit')) {
$this->error['warning'] = $this->language->get('error_permission');
}
/* End Block*/
/* Block to check if the helloworld_text_field is properly set to save into database, otherwise the error is returned*/
/*
if (!$this->request->post['PaymentMethodDescription']) {
$this->error['description'] = $this->language->get('error_description');
}
*/
/* End Block*/
/* if (!$this->request->post['redirecturl']) {
$this->error['redirecturl'] = $this->language->get('error_redirecturl');
}*/
return !$this->error;
}
/* End Validation Function*/
}
?>
Your controller file should look like this:
<?php
class ControllerExtensionPaymentIcredit extends Controller {
private $error = array();
public function install()
{
$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "iCredit` (
`id_icredit` int(1) NOT NULL AUTO_INCREMENT,
`enabled` varchar(255),
`PaymentMethodDescription` varchar(500) CHARACTER SET utf8,
`title` varchar(255) CHARACTER SET utf8,
`testmode` varchar(1),
`testtoken` varchar(255),
`grouptoken` varchar(500),
`maxpayment` varchar(255),
`creditpayment` varchar(500),
`windowtype` varchar(255),
`height` int(10),
`width` int(10),
`hideitemlist` varchar(1),
`createtoken` varchar(1),
`invoicelang` varchar(500),
`exemptvat` varchar(255),
`redirecturl` varchar(500),
`ipn` varchar(500),
`sortorder` varchar(500),
`date_added` datetime,
PRIMARY KEY (`id_icredit`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; ");
}
public function uninstall()
{
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "iCredit");
}
public function index()
{ // Default function
$this->install();
$this->load->language('extension/payment/icredit'); // Loading the language file of helloworld
$this->document->setTitle($this->language->get('heading_title')); // Set the title of the page to the heading title in the Language file i.e., Hello World
$this->load->model('setting/setting');
$this->load->model('extension/payment/icredit'); // Load the Setting Model (All of the OpenCart Module & General Settings are saved using this Model )
//fwrite($file,$this->validate()." -- validate\r\n");
//fwrite($file,print_r($_POST,TRUE)." -- post\r\n");
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate())
{
if ($this->request->post['icredit_id'] == "")
{
$this->model_setting_setting->editSetting('payment_icredit', $this->request->post);
$check = $this->model_extension_payment_icredit->addicreditsettings($this->request->post);
}
else
{
$this->model_setting_setting->editSetting('payment_icredit', $this->request->post);
$check = $this->model_extension_payment_icredit->editicreditsettings($this->request->post);
}
$this->session->data['success'] = $this->language->get('text_success'); // To display the success text on data save=
if($check == 1)
{
$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)); // Redirect to the Module Listing
}
}
/*Assign the language data for parsing it to view*/
$data['heading_title'] = $this->language->get('heading_title');
$this->load->model('localisation/order_status');
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
// return warning if any*/
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['description'])) {
$data['description'] = $this->error['description'];
} else {
$data['description'] = '';
}
/* Making of Breadcrumbs to be displayed on site*/
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_extension'),
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('extension/payment/icredit', 'user_token=' . $this->session->data['user_token'], true)
);
$data['action'] = $this->url->link('extension/payment/icredit', 'user_token=' . $this->session->data['user_token'], true);
$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true);
/* This block checks, if the hello world text field is set it parses it to view otherwise get the default hello world text field from the database and parse it*/
if (isset($this->request->post['PaymentMethodDescription'])) {
$data['PaymentMethodDescription'] = $this->request->post['PaymentMethodDescription'];
} else {
$data['PaymentMethodDescription'] = $this->config->get('PaymentMethodDescription');
}
if (isset($this->request->post['payment_icredit_complete_order_status_id'])) {
$data['payment_icredit_complete_order_status_id'] = $this->request->post['payment_icredit_complete_order_status_id'];
} else {
$data['payment_icredit_complete_order_status_id'] = $this->config->get('payment_icredit_complete_order_status_id');
}
if (isset($this->request->post['payment_icredit_pending_order_status_id'])) {
$data['payment_icredit_pending_order_status_id'] = $this->request->post['payment_icredit_pending_order_status_id'];
} else {
$data['payment_icredit_pending_order_status_id'] = $this->config->get('payment_icredit_pending_order_status_id');
}
if (isset($this->request->post['payment_icredit_processing_order_status_id'])) {
$data['payment_icredit_processing_order_status_id'] = $this->request->post['payment_icredit_processing_order_status_id'];
} else {
$data['payment_icredit_processing_order_status_id'] = $this->config->get('payment_icredit_processing_order_status_id');
}
/* End Block*/
$data['modules'] = array();
/* This block parses the Module Settings such as Layout, Position,Status & Order Status to the view*/
if (isset($this->request->post['PaymentMethodDescription'])) {
$data['modules'] = $this->request->post['PaymentMethodDescription'];
} elseif ($this->config->get('PaymentMethodDescription')) {
$data['modules'] = $this->config->get('PaymentMethodDescription');
}
/* End Block*/
$this->load->model('design/layout'); // Loading the Design Layout Models
$data['layouts'] = $this->model_design_layout->getLayouts(); // Getting all the Layouts available on system
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$getsettings = $this->model_extension_payment_icredit->addGeticreditsettings();
$data['editdata']=array();
if(isset($getsettings))
{
$data['editdata']['icredit_id'] = $getsettings['id_icredit'];
$data['editdata']['enabled'] = $getsettings['enabled'];
$data['editdata']['PaymentMethodDescription'] = $getsettings['PaymentMethodDescription'];
$data['editdata']['title'] = $getsettings['title'];
$data['editdata']['testmode'] = $getsettings['testmode'];
$data['editdata']['testtoken'] = $getsettings['testtoken'];
$data['editdata']['grouptoken'] = $getsettings['grouptoken'];
$data['editdata']['maxpayment'] = $getsettings['maxpayment'];
$data['editdata']['creditpayment'] = $getsettings['creditpayment'];
$data['editdata']['windowtype'] = $getsettings['windowtype'];
$data['editdata']['height'] = $getsettings['height'];
$data['editdata']['width'] = $getsettings['width'];
$data['editdata']['hideitemlist'] = $getsettings['hideitemlist'];
$data['editdata']['createtoken'] = $getsettings['createtoken'];
$data['editdata']['invoicelang'] = $getsettings['invoicelang'];
$data['editdata']['exemptvat'] = $getsettings['exemptvat'];
$data['editdata']['redirecturl'] = $getsettings['redirecturl'];
$data['editdata']['ipn'] = $getsettings['ipn'];
$data['editdata']['sortorder'] = $getsettings['sortorder'];
}
$data['editdata'] = $data['editdata'];
$this->response->setoutput($this->load->view('extension/payment/icredit.twig', $data));
}
protected function validate() {
/* Block to check the user permission to manipulate the module*/
if (!$this->user->hasPermission('modify', 'extension/payment/icredit')) {
$this->error['warning'] = $this->language->get('error_permission');
}
/* End Block*/
/* Block to check if the helloworld_text_field is properly set to save into database, otherwise the error is returned*/
/*
if (!$this->request->post['PaymentMethodDescription']) {
$this->error['description'] = $this->language->get('error_description');
}
*/
/* End Block*/
/* if (!$this->request->post['redirecturl']) {
$this->error['redirecturl'] = $this->language->get('error_redirecturl');
}*/
return !$this->error;
}
/* End Validation Function*/
}
I'm not sure it is will works because i do not see another files.
In your twig file you must find this strings:
icredit_complete_order_status_id
icredit_pending_order_status_id
icredit_processing_order_status_id
and replace with:
payment_icredit_complete_order_status_id
payment_icredit_pending_order_status_id
payment_icredit_processing_order_status_id

Dynamic If else statement, value for condition is from database

is there a way to make this if else condition:
$searchUserTypeName = UserType::findOrFail(1);
success = true;
$message = '';
$user = new User();
if ($searchUserTypeName->name == "Captain" || $searchUserTypeName->name == "Member") {
$fields = [
'teacher_id' => 'Teacher Id',
'team_id' => 'Team',
'mobile' => 'Mobile',
'launched_date' => 'Launched Date',
'endorsed_date' => 'Endorsed Date'
];
} else if ($searchUserTypeName->name == "Mentor" || $searchUserTypeName->name == "Mentee") {
$fields = [
'teacher_id' => 'Teacher Id',
'team_id' => 'Team',
'skype_id' => 'Skype Id',
'google_hangouts' => 'Google Hangouts',
'graduation_date' => 'Graduation Date',
'launched_date' => 'Launched Date',
'endorsed_date' => 'Endorsed Date'
];
}
foreach ($fields as $key => $field) {
if (!$request->has($key) || $request->{$key} == '') {
$success = false;
$message .= $field . ' is required.<br>';
} else {
$user->{$key} = $request->{$key};
}
}
if (!$success) {
$this->setStatus(400);
$this->setSuccess(false);
$this->setMessage($message);
return $this->sendResponse($fields);
}
$user->save();
to dynamic?
The value Captain, Member, Mentor and Mentee is from a mysql table
if Captain or Member
there is a specific field select that will save on the use tabel
same as for Mentor and Mentee
hope you can help
thanks
You can set method in your related model
User extends Model {
public function isName(...$names)
{
return in_array($this->name, $names);
}
}
if ($user->isName('Captain', 'Member')) {
//
}

OpenCart order tracking without login

i'm using opencart 1.5.6.3, i'm trying to display a page with 2 field. 1 field will be use for Email and another field for Order ID. So client can see their order status directly without login.
thanks in advance.
After so much try, I got solution.
Add new file to
catalog> controller> account> guest.php
<?php class ControllerAccountGuest extends Controller {
private $error = array();
public function index() {
$this->language->load('account/guest');
$this->document->setTitle($this->language->get('heading_title'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['entry_email'] = $this->language->get('entry_email');
$this->data['entry_ip'] = $this->language->get('entry_ip');
$this->data['entry_order_id'] = $this->language->get('entry_order_id');
$this->data['text_err'] = $this->language->get('text_err');
$this->data['text_ip'] = $this->language->get('text_ip');
$this->data['text_order_id'] = $this->language->get('text_order_id');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['action'] = $this->url->link('account/guest/info', '', 'SSL');
$this->data['continue'] = $this->url->link('account/guest', '', 'SSL');
if (isset($this->request->get['email'])) {
$this->data['email'] = $this->request->get['email'];
} else {
$this->data['email'] = '';
}
if (isset($this->request->get['ip'])) {
$this->data['ip'] = $this->request->get['ip'];
} else {
$this->data['ip'] = '';
}
if (isset($this->request->get['order_id'])) {
$this->data['order_id'] = $this->request->get['order_id'];
} else {
$this->data['order_id'] = '';
}
// Nacteni chybovych hlaseni
$err = array(
'email' => false,
'ip' => false,
'order_id' => false,
);
if (isset($this->request->get['err'])) {
$err_temp = explode('|', $this->request->get['err']);
foreach ($err_temp as $value) {
$err[$value] = true;
} // foreach
}
$this->data['err'] = $err;
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/guest_login.tpl')) {
$this->template = $this->config->get('config_template') . '/template/account/guest_login.tpl';
} else {
$this->template = 'default/template/account/guest_login.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
public function info() {
$err = false;
$url = '';
if ( isset($this->request->post['email']) AND strlen($this->request->post['email']) > 4 ) {
$email = $this->request->post['email'];
$url .= '&email=' . $this->request->post['email'];
} else {
$email = '';
$err = ( $err ? $err . '|' . 'email' : 'email' );
}
/*
if (isset($this->request->post['ip'])) {
$ip = $this->request->post['ip'];
$url .= '&ip=' . $this->request->post['ip'];
} else {
$ip = '0';
$err = ( $err ? $err . '|' . 'ip' : 'ip' );
}
*/
if ( isset($this->request->post['order_id']) AND is_numeric($this->request->post['order_id']) ) {
$order_id = $this->request->post['order_id'];
$url .= '&order_id=' . $this->request->post['order_id'];
} else {
$order_id = '0';
$err = ( $err ? $err . '|' . 'order_id' : 'order_id' );
}
if ($err) {
$url .= '&err=' . $err;
$this->redirect($this->url->link('account/guest', 'token=' . $this->session->data['token'] . $url, 'SSL'));
}
$this->language->load('account/guest_history');
$this->load->model('account/guest');
//$order_info = $this->model_account_guest->getOrder($order_id, $email, $ip);
$order_info = $this->model_account_guest->getOrder($order_id, $email);
if ($order_info) {
$this->document->setTitle($this->language->get('text_order'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('text_order');
$this->data['text_order_detail'] = $this->language->get('text_order_detail');
$this->data['text_invoice_no'] = $this->language->get('text_invoice_no');
$this->data['text_order_id'] = $this->language->get('text_order_id');
$this->data['text_date_added'] = $this->language->get('text_date_added');
$this->data['text_shipping_method'] = $this->language->get('text_shipping_method');
$this->data['text_shipping_address'] = $this->language->get('text_shipping_address');
$this->data['text_payment_method'] = $this->language->get('text_payment_method');
$this->data['text_payment_address'] = $this->language->get('text_payment_address');
$this->data['text_history'] = $this->language->get('text_history');
$this->data['text_comment'] = $this->language->get('text_comment');
$this->data['text_action'] = $this->language->get('text_action');
$this->data['text_selected'] = $this->language->get('text_selected');
$this->data['text_reorder'] = $this->language->get('text_reorder');
$this->data['text_return'] = $this->language->get('text_return');
$this->data['column_name'] = $this->language->get('column_name');
$this->data['column_model'] = $this->language->get('column_model');
$this->data['column_quantity'] = $this->language->get('column_quantity');
$this->data['column_price'] = $this->language->get('column_price');
$this->data['column_total'] = $this->language->get('column_total');
$this->data['column_date_added'] = $this->language->get('column_date_added');
$this->data['column_status'] = $this->language->get('column_status');
$this->data['column_comment'] = $this->language->get('column_comment');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['action'] = $this->url->link('account/order/info', 'order_id=' . $order_id , 'SSL');
if ($order_info['invoice_no']) {
$this->data['invoice_no'] = $order_info['invoice_prefix'] . $order_info['invoice_no'];
} else {
$this->data['invoice_no'] = '';
}
$this->data['order_id'] = $order_id ;
$this->data['date_added'] = date($this->language->get('date_format_short'), strtotime($order_info['date_added']));
if ($order_info['shipping_address_format']) {
$format = $order_info['shipping_address_format'];
} else {
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $order_info['shipping_firstname'],
'lastname' => $order_info['shipping_lastname'],
'company' => $order_info['shipping_company'],
'address_1' => $order_info['shipping_address_1'],
'address_2' => $order_info['shipping_address_2'],
'city' => $order_info['shipping_city'],
'postcode' => $order_info['shipping_postcode'],
'zone' => $order_info['shipping_zone'],
'zone_code' => $order_info['shipping_zone_code'],
'country' => $order_info['shipping_country']
);
$this->data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
$this->data['shipping_method'] = $order_info['shipping_method'];
if ($order_info['payment_address_format']) {
$format = $order_info['payment_address_format'];
} else {
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $order_info['payment_firstname'],
'lastname' => $order_info['payment_lastname'],
'company' => $order_info['payment_company'],
'address_1' => $order_info['payment_address_1'],
'address_2' => $order_info['payment_address_2'],
'city' => $order_info['payment_city'],
'postcode' => $order_info['payment_postcode'],
'zone' => $order_info['payment_zone'],
'zone_code' => $order_info['payment_zone_code'],
'country' => $order_info['payment_country']
);
$this->data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
$this->data['payment_method'] = $order_info['payment_method'];
$this->data['products'] = array();
$products = $this->model_account_guest->getOrderProducts($order_id );
foreach ($products as $product) {
$option_data = array();
$options = $this->model_account_guest->getOrderOptions($order_id , $product['order_product_id']);
foreach ($options as $option) {
if ($option['type'] != 'file') {
$option_data[] = array(
'name' => $option['name'],
'value' => (strlen($option['value']) > 20 ? substr($option['value'], 0, 20) . '..' : $option['value']),
);
} else {
$filename = substr($option['value'], 0, strrpos($option['value'], '.'));
$option_data[] = array(
'name' => $option['name'],
'value' => (strlen($filename) > 20 ? substr($filename, 0, 20) . '..' : $filename)
);
}
} // foreach
$this->data['products'][] = array(
'order_product_id' => $product['order_product_id'],
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'quantity' => $product['quantity'],
'price' => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']),
'total' => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value']),
'selected' => isset($this->request->post['selected']) && in_array($result['order_product_id'], $this->request->post['selected'])
);
}
$this->data['totals'] = $this->model_account_guest->getOrderTotals($order_id );
$this->data['comment'] = $order_info['comment'];
$this->data['histories'] = array();
$results = $this->model_account_guest->getOrderHistories($order_id );
foreach ($results as $result) {
$this->data['histories'][] = array(
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'status' => $result['status'],
'comment' => nl2br($result['comment'])
);
} // foreach
$this->data['continue'] = $this->url->link('account/order', '', 'SSL');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/guest_history.tpl')) {
$this->template = $this->config->get('config_template') . '/template/account/guest_history.tpl';
} else {
$this->template = 'default/template/account/guest_history.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
} else {
$this->document->setTitle($this->language->get('text_order'));
$this->data['heading_title'] = $this->language->get('text_order');
$this->data['text_error'] = $this->language->get('text_error');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$this->data['continue'] = $this->url->link('account/order', '', 'SSL');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
} else {
$this->template = 'default/template/error/not_found.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}} // info
private function validate() {
if (!isset($this->request->post['selected']) || !isset($this->request->post['action']) || !$this->request->post['action']) {
$this->error['warning'] = $this->language->get('error_warning');
}
if (!$this->error) {
return true;
} else {
return false;
}
} // validate } ?>
Add another new file to catalog> model> account> guest.php
<?php class ModelAccountGuest extends Model { //public function getOrder($order_id, $email, $ip) { public function getOrder($order_id, $email) {
$order_query = $this->db->query("
SELECT *
FROM `" . DB_PREFIX . "order`
WHERE order_id = '" . (int)$order_id . "'
AND email = '" . $this->db->escape($email) . "'
AND order_status_id > '0'
"); // AND ip = '" . $this->db->escape($ip) . "'
if ($order_query->num_rows) {
$country_query = $this->db->query("
SELECT *
FROM `" . DB_PREFIX . "country`
WHERE country_id = '" . (int)$order_query->row['shipping_country_id'] . "'
");
if ($country_query->num_rows) {
$shipping_iso_code_2 = $country_query->row['iso_code_2'];
$shipping_iso_code_3 = $country_query->row['iso_code_3'];
} else {
$shipping_iso_code_2 = '';
$shipping_iso_code_3 = '';
}
$zone_query = $this->db->query("
SELECT *
FROM `" . DB_PREFIX . "zone`
WHERE zone_id = '" . (int)$order_query->row['shipping_zone_id'] . "'
");
if ($zone_query->num_rows) {
$shipping_zone_code = $zone_query->row['code'];
} else {
$shipping_zone_code = '';
}
$country_query = $this->db->query("
SELECT *
FROM `" . DB_PREFIX . "country`
WHERE country_id = '" . (int)$order_query->row['payment_country_id'] . "'
");
if ($country_query->num_rows) {
$payment_iso_code_2 = $country_query->row['iso_code_2'];
$payment_iso_code_3 = $country_query->row['iso_code_3'];
} else {
$payment_iso_code_2 = '';
$payment_iso_code_3 = '';
}
$zone_query = $this->db->query("
SELECT *
FROM `" . DB_PREFIX . "zone`
WHERE zone_id = '" . (int)$order_query->row['payment_zone_id'] . "'
");
if ($zone_query->num_rows) {
$payment_zone_code = $zone_query->row['code'];
} else {
$payment_zone_code = '';
}
return array(
'order_id' => $order_query->row['order_id'],
'invoice_no' => $order_query->row['invoice_no'],
'invoice_prefix' => $order_query->row['invoice_prefix'],
'store_id' => $order_query->row['store_id'],
'store_name' => $order_query->row['store_name'],
'store_url' => $order_query->row['store_url'],
'customer_id' => $order_query->row['customer_id'],
'firstname' => $order_query->row['firstname'],
'lastname' => $order_query->row['lastname'],
'telephone' => $order_query->row['telephone'],
'fax' => $order_query->row['fax'],
'email' => $order_query->row['email'],
'shipping_firstname' => $order_query->row['shipping_firstname'],
'shipping_lastname' => $order_query->row['shipping_lastname'],
'shipping_company' => $order_query->row['shipping_company'],
'shipping_address_1' => $order_query->row['shipping_address_1'],
'shipping_address_2' => $order_query->row['shipping_address_2'],
'shipping_postcode' => $order_query->row['shipping_postcode'],
'shipping_city' => $order_query->row['shipping_city'],
'shipping_zone_id' => $order_query->row['shipping_zone_id'],
'shipping_zone' => $order_query->row['shipping_zone'],
'shipping_zone_code' => $shipping_zone_code,
'shipping_country_id' => $order_query->row['shipping_country_id'],
'shipping_country' => $order_query->row['shipping_country'],
'shipping_iso_code_2' => $shipping_iso_code_2,
'shipping_iso_code_3' => $shipping_iso_code_3,
'shipping_address_format' => $order_query->row['shipping_address_format'],
'shipping_method' => $order_query->row['shipping_method'],
'payment_firstname' => $order_query->row['payment_firstname'],
'payment_lastname' => $order_query->row['payment_lastname'],
'payment_company' => $order_query->row['payment_company'],
'payment_address_1' => $order_query->row['payment_address_1'],
'payment_address_2' => $order_query->row['payment_address_2'],
'payment_postcode' => $order_query->row['payment_postcode'],
'payment_city' => $order_query->row['payment_city'],
'payment_zone_id' => $order_query->row['payment_zone_id'],
'payment_zone' => $order_query->row['payment_zone'],
'payment_zone_code' => $payment_zone_code,
'payment_country_id' => $order_query->row['payment_country_id'],
'payment_country' => $order_query->row['payment_country'],
'payment_iso_code_2' => $payment_iso_code_2,
'payment_iso_code_3' => $payment_iso_code_3,
'payment_address_format' => $order_query->row['payment_address_format'],
'payment_method' => $order_query->row['payment_method'],
'comment' => $order_query->row['comment'],
'total' => $order_query->row['total'],
'order_status_id' => $order_query->row['order_status_id'],
'language_id' => $order_query->row['language_id'],
'currency_id' => $order_query->row['currency_id'],
'currency_code' => $order_query->row['currency_code'],
'currency_value' => $order_query->row['currency_value'],
'date_modified' => $order_query->row['date_modified'],
'date_added' => $order_query->row['date_added'],
'ip' => $order_query->row['ip']
);
} else {
return false;
}
} // getOrder
public function getOrderProducts($order_id) {
$query = $this->db->query("
SELECT *
FROM " . DB_PREFIX . "order_product
WHERE order_id = '" . (int)$order_id . "'
");
return $query->rows;
} // getOrderProducts
public function getOrderOptions($order_id, $order_product_id) {
$query = $this->db->query("
SELECT *
FROM " . DB_PREFIX . "order_option
WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product_id . "'
");
return $query->rows;
} // getOrderOptions
public function getOrderTotals($order_id) {
$query = $this->db->query("
SELECT *
FROM " . DB_PREFIX . "order_total
WHERE order_id = '" . (int)$order_id . "'
ORDER BY sort_order
");
return $query->rows;
} // getOrderTotals
public function getOrderHistories($order_id) {
$query = $this->db->query("
SELECT date_added, os.name AS status, oh.comment, oh.notify
FROM " . DB_PREFIX . "order_history oh
LEFT JOIN " . DB_PREFIX . "order_status os ON oh.order_status_id = os.order_status_id
WHERE oh.order_id = '" . (int)$order_id . "'
AND os.language_id = '" . (int)$this->config->get('config_language_id') . "'
ORDER BY oh.date_added
"); // AND oh.notify = '1'
return $query->rows;
} // getOrderHistories
public function getOrderDownloads($order_id) {
$query = $this->db->query("
SELECT *
FROM " . DB_PREFIX . "order_download
WHERE order_id = '" . (int)$order_id . "'
ORDER BY name
");
return $query->rows;
} // getOrderDownloads
public function getTotalOrders() {
$query = $this->db->query("
SELECT COUNT(*) AS total
FROM `" . DB_PREFIX . "order`
WHERE customer_id = '" . (int)$this->customer->getId() . "' AND order_status_id > '0'
");
return $query->row['total'];
} // getTotalOrders
public function getTotalOrderProductsByOrderId($order_id) {
$query = $this->db->query("
SELECT COUNT(*) AS total
FROM " . DB_PREFIX . "order_product
WHERE order_id = '" . (int)$order_id . "'
");
return $query->row['total'];
} // getTotalOrderProductsByOrderId } // class ?>
Now add language file to catalog> language> english> account>
<?php // Heading $_['heading_title'] = 'Order Tracking'; // Text $_['text_account'] = 'Account'; // Entry $_['entry_email'] = 'E-Mail Address:'; $_['entry_ip'] = 'IP Address:'; $_['entry_order_id'] = 'Order Number:'; $_['text_err'] = '<span style="color:red;"> <<< </span>'; $_['text_ip'] = 'eg. 123.345.456.678 - Find this on you order email in the \'Order Details\' section:'; $_['text_order_id'] = 'eg. 123 - Find this on you order email in the \'Order Details\' section:'; // Error $_['error_login'] = 'Warning: No match for E-Mail Address and/or Order Number.'; ?>
Now add tlp file to catalog> view> theme> default> template> account> guest_login.tlp with form action and submit button then add this java script:
<script type="text/javascript"><!-- $('#login input').keydown(function(e) {
if (e.keyCode == 13) {
$('#login').submit();
} }); //--></script>
Now add another file to show result. Catalog> view> theme> default> template> account> guest_history.tlp
Checked in OpenCart 1.5.6.3 with custom theme.

cart gets empty after adding a product and moving to checkout or cart in opencart

Im having a very strange problem. When i add a product to my shopping cart on top header it shows the cart details/products. But when i click on the cart or checkout it says my cart is empty. So each time when i add the product and move to checkout or cart it automatically becomes empty.
I have tried the site on firefox, chrome and in different PCs but still the same problem. But the weird part is when i run firebug and move to the console to see the calls, the site works perfectly. But when i close firebug and refresh the page or move the cart becomes empty again.
Can someone tell me what might the problem be?
Im using Opencart 1.5.4
Checkout controller function
public function index() {
// Validate cart has products and has stock.
if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) {
$this->redirect($this->url->link('checkout/cart'));
}
// Validate minimum quantity requirments.
$products = $this->cart->getProducts();
foreach ($products as $product) {
$product_total = 0;
foreach ($products as $product_2) {
if ($product_2['product_id'] == $product['product_id']) {
$product_total += $product_2['quantity'];
}
}
if ($product['minimum'] > $product_total) {
$this->redirect($this->url->link('checkout/cart'));
}
}
$this->language->load('checkout/checkout');
$this->document->setTitle($this->language->get('heading_title'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_cart'),
'href' => $this->url->link('checkout/cart'),
'separator' => $this->language->get('text_separator')
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('checkout/checkout', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_checkout_option'] = $this->language->get('text_checkout_option');
$this->data['text_checkout_account'] = $this->language->get('text_checkout_account');
$this->data['text_checkout_payment_address'] = $this->language->get('text_checkout_payment_address');
$this->data['text_checkout_shipping_address'] = $this->language->get('text_checkout_shipping_address');
$this->data['text_checkout_shipping_method'] = $this->language->get('text_checkout_shipping_method');
$this->data['text_checkout_payment_method'] = $this->language->get('text_checkout_payment_method');
$this->data['text_checkout_confirm'] = $this->language->get('text_checkout_confirm');
$this->data['text_modify'] = $this->language->get('text_modify');
$this->data['logged'] = $this->customer->isLogged();
$this->data['shipping_required'] = $this->cart->hasShipping();
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/checkout.tpl')) {
$this->template = $this->config->get('config_template') . '/template/checkout/checkout.tpl';
} else {
$this->template = 'default/template/checkout/checkout.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
cart controller
public function index() {
$this->language->load('checkout/cart');
if (!isset($this->session->data['vouchers'])) {
$this->session->data['vouchers'] = array();
}
// Update
if (!empty($this->request->post['quantity'])) {
foreach ($this->request->post['quantity'] as $key => $value) {
$this->cart->update($key, $value);
}
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['reward']);
$this->redirect($this->url->link('checkout/cart'));
}
// Remove
if (isset($this->request->get['remove'])) {
$this->cart->remove($this->request->get['remove']);
unset($this->session->data['vouchers'][$this->request->get['remove']]);
$this->session->data['success'] = $this->language->get('text_remove');
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['reward']);
$this->redirect($this->url->link('checkout/cart'));
}
// Coupon
if (isset($this->request->post['coupon']) && $this->validateCoupon()) {
$this->session->data['coupon'] = $this->request->post['coupon'];
$this->session->data['success'] = $this->language->get('text_coupon');
$this->redirect($this->url->link('checkout/cart'));
}
// Voucher
if (isset($this->request->post['voucher']) && $this->validateVoucher()) {
$this->session->data['voucher'] = $this->request->post['voucher'];
$this->session->data['success'] = $this->language->get('text_voucher');
$this->redirect($this->url->link('checkout/cart'));
}
// Reward
if (isset($this->request->post['reward']) && $this->validateReward()) {
$this->session->data['reward'] = abs($this->request->post['reward']);
$this->session->data['success'] = $this->language->get('text_reward');
$this->redirect($this->url->link('checkout/cart'));
}
// Shipping
if (isset($this->request->post['shipping_method']) && $this->validateShipping()) {
$shipping = explode('.', $this->request->post['shipping_method']);
$this->session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]];
$this->session->data['success'] = $this->language->get('text_shipping');
$this->redirect($this->url->link('checkout/cart'));
}
$this->document->setTitle($this->language->get('heading_title'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'href' => $this->url->link('common/home'),
'text' => $this->language->get('text_home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'href' => $this->url->link('checkout/cart'),
'text' => $this->language->get('heading_title'),
'separator' => $this->language->get('text_separator')
);
if ($this->cart->hasProducts() || !empty($this->session->data['vouchers'])) {
$points = $this->customer->getRewardPoints();
$points_total = 0;
foreach ($this->cart->getProducts() as $product) {
if ($product['points']) {
$points_total += $product['points'];
}
}
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_next'] = $this->language->get('text_next');
$this->data['text_next_choice'] = $this->language->get('text_next_choice');
$this->data['text_use_coupon'] = $this->language->get('text_use_coupon');
$this->data['text_use_voucher'] = $this->language->get('text_use_voucher');
$this->data['text_use_reward'] = sprintf($this->language->get('text_use_reward'), $points);
$this->data['text_shipping_estimate'] = $this->language->get('text_shipping_estimate');
$this->data['text_shipping_detail'] = $this->language->get('text_shipping_detail');
$this->data['text_shipping_method'] = $this->language->get('text_shipping_method');
$this->data['text_select'] = $this->language->get('text_select');
$this->data['text_none'] = $this->language->get('text_none');
$this->data['column_image'] = $this->language->get('column_image');
$this->data['column_name'] = $this->language->get('column_name');
$this->data['column_model'] = $this->language->get('column_model');
$this->data['column_quantity'] = $this->language->get('column_quantity');
$this->data['column_price'] = $this->language->get('column_price');
$this->data['column_total'] = $this->language->get('column_total');
$this->data['entry_coupon'] = $this->language->get('entry_coupon');
$this->data['entry_voucher'] = $this->language->get('entry_voucher');
$this->data['entry_reward'] = sprintf($this->language->get('entry_reward'), $points_total);
$this->data['entry_country'] = $this->language->get('entry_country');
$this->data['entry_zone'] = $this->language->get('entry_zone');
$this->data['entry_postcode'] = $this->language->get('entry_postcode');
$this->data['button_update'] = $this->language->get('button_update');
$this->data['button_remove'] = $this->language->get('button_remove');
$this->data['button_coupon'] = $this->language->get('button_coupon');
$this->data['button_voucher'] = $this->language->get('button_voucher');
$this->data['button_reward'] = $this->language->get('button_reward');
$this->data['button_quote'] = $this->language->get('button_quote');
$this->data['button_shipping'] = $this->language->get('button_shipping');
$this->data['button_shopping'] = $this->language->get('button_shopping');
$this->data['button_checkout'] = $this->language->get('button_checkout');
if (isset($this->error['warning'])) {
$this->data['error_warning'] = $this->error['warning'];
} elseif (!$this->cart->hasStock() && (!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning'))) {
$this->data['error_warning'] = $this->language->get('error_stock');
} else {
$this->data['error_warning'] = '';
}
if ($this->config->get('config_customer_price') && !$this->customer->isLogged()) {
$this->data['attention'] = sprintf($this->language->get('text_login'), $this->url->link('account/login'), $this->url->link('account/register'));
} else {
$this->data['attention'] = '';
}
if (isset($this->session->data['success'])) {
$this->data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$this->data['success'] = '';
}
$this->data['action'] = $this->url->link('checkout/cart');
if ($this->config->get('config_cart_weight')) {
$this->data['weight'] = $this->weight->format($this->cart->getWeight(), $this->config->get('config_weight_class_id'), $this->language->get('decimal_point'), $this->language->get('thousand_point'));
} else {
$this->data['weight'] = '';
}
$this->load->model('tool/image');
$this->data['products'] = array();
$products = $this->cart->getProducts();
foreach ($products as $product) {
$product_total = 0;
foreach ($products as $product_2) {
if ($product_2['product_id'] == $product['product_id']) {
$product_total += $product_2['quantity'];
}
}
if ($product['minimum'] > $product_total) {
$this->data['error_warning'] = sprintf($this->language->get('error_minimum'), $product['name'], $product['minimum']);
}
if ($product['image']) {
$image = $this->model_tool_image->resize($product['image'], $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'));
} else {
$image = '';
}
$option_data = array();
foreach ($product['option'] as $option) {
if ($option['type'] != 'file') {
$value = $option['option_value'];
} else {
$filename = $this->encryption->decrypt($option['option_value']);
$value = utf8_substr($filename, 0, utf8_strrpos($filename, '.'));
}
$option_data[] = array(
'name' => $option['name'],
'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value)
);
}
// Display prices
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = false;
}
// Display prices
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$total = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity']);
} else {
$total = false;
}
$this->data['products'][] = array(
'key' => $product['key'],
'thumb' => $image,
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'quantity' => $product['quantity'],
'stock' => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
'reward' => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''),
'price' => $price,
'total' => $total,
'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']),
'remove' => $this->url->link('checkout/cart', 'remove=' . $product['key'])
);
}
// Gift Voucher
$this->data['vouchers'] = array();
if (!empty($this->session->data['vouchers'])) {
foreach ($this->session->data['vouchers'] as $key => $voucher) {
$this->data['vouchers'][] = array(
'key' => $key,
'description' => $voucher['description'],
'amount' => $this->currency->format($voucher['amount']),
'remove' => $this->url->link('checkout/cart', 'remove=' . $key)
);
}
}
if (isset($this->request->post['next'])) {
$this->data['next'] = $this->request->post['next'];
} else {
$this->data['next'] = '';
}
$this->data['coupon_status'] = $this->config->get('coupon_status');
if (isset($this->request->post['coupon'])) {
$this->data['coupon'] = $this->request->post['coupon'];
} elseif (isset($this->session->data['coupon'])) {
$this->data['coupon'] = $this->session->data['coupon'];
} else {
$this->data['coupon'] = '';
}
$this->data['voucher_status'] = $this->config->get('voucher_status');
if (isset($this->request->post['voucher'])) {
$this->data['voucher'] = $this->request->post['voucher'];
} elseif (isset($this->session->data['voucher'])) {
$this->data['voucher'] = $this->session->data['voucher'];
} else {
$this->data['voucher'] = '';
}
$this->data['reward_status'] = ($points && $points_total && $this->config->get('reward_status'));
if (isset($this->request->post['reward'])) {
$this->data['reward'] = $this->request->post['reward'];
} elseif (isset($this->session->data['reward'])) {
$this->data['reward'] = $this->session->data['reward'];
} else {
$this->data['reward'] = '';
}
$this->data['shipping_status'] = $this->config->get('shipping_status') && $this->config->get('shipping_estimator') && $this->cart->hasShipping();
if (isset($this->request->post['country_id'])) {
$this->data['country_id'] = $this->request->post['country_id'];
} elseif (isset($this->session->data['shipping_country_id'])) {
$this->data['country_id'] = $this->session->data['shipping_country_id'];
} else {
$this->data['country_id'] = $this->config->get('config_country_id');
}
$this->load->model('localisation/country');
$this->data['countries'] = $this->model_localisation_country->getCountries();
if (isset($this->request->post['zone_id'])) {
$this->data['zone_id'] = $this->request->post['zone_id'];
} elseif (isset($this->session->data['shipping_zone_id'])) {
$this->data['zone_id'] = $this->session->data['shipping_zone_id'];
} else {
$this->data['zone_id'] = '';
}
if (isset($this->request->post['postcode'])) {
$this->data['postcode'] = $this->request->post['postcode'];
} elseif (isset($this->session->data['shipping_postcode'])) {
$this->data['postcode'] = $this->session->data['shipping_postcode'];
} else {
$this->data['postcode'] = '';
}
if (isset($this->request->post['shipping_method'])) {
$this->data['shipping_method'] = $this->request->post['shipping_method'];
} elseif (isset($this->session->data['shipping_method'])) {
$this->data['shipping_method'] = $this->session->data['shipping_method']['code'];
} else {
$this->data['shipping_method'] = '';
}
// Totals
$this->load->model('setting/extension');
$total_data = array();
$total = 0;
$taxes = $this->cart->getTaxes();
// Display prices
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$sort_order = array();
$results = $this->model_setting_extension->getExtensions('total');
foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
}
array_multisort($sort_order, SORT_ASC, $results);
foreach ($results as $result) {
if ($this->config->get($result['code'] . '_status')) {
$this->load->model('total/' . $result['code']);
$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
}
$sort_order = array();
foreach ($total_data as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $total_data);
}
}
$this->data['totals'] = $total_data;
$this->data['continue'] = $this->url->link('common/home');
$this->data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/cart.tpl')) {
$this->template = $this->config->get('config_template') . '/template/checkout/cart.tpl';
} else {
$this->template = 'default/template/checkout/cart.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_bottom',
'common/content_top',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
} else {
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_error'] = $this->language->get('text_empty');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['continue'] = $this->url->link('common/home');
unset($this->session->data['success']);
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
} else {
$this->template = 'default/template/error/not_found.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
}
session library
class Session {
public $data = array();
public function __construct() {
if (!session_id()) {
ini_set('session.use_cookies', 'On');
ini_set('session.use_trans_sid', 'Off');
session_set_cookie_params(0, '/');
session_start();
}
$this->data =& $_SESSION;
}
function getId() {
return session_id();
}
}
It's extremely hard to say, where's the root of the problem. If you have any 3rd party extensions (VQMods), they can change original OpenCart code. In this case you should look in cached files, not original ones. That's for the start.

Activation form does not fully work

i hope someone can help with this. At one point i thought i had this working but cannot figure out why it is not.
The script below does everything but include the Zend_Json::encode. It saves the user in the database it emails the person a link, however the link does not have the encryption included with it.
thanks for your help!
public function contribjoinAction()
{
$request = $this->getRequest();
$conn = XXX_Db_Connection::factory()->getMasterConnection();
$userDao = XXX_Model_Dao_Factory::getInstance()->setModule('core')->getUserDao();
$userDao->setDbConnection($conn);
if ($request->isPost()) {
$fullname = $request->getPost('full_name');
$username = $request->getPost('username');
$password = $request->getPost('password');
$password2 = $request->getPost('confirmPassword');
$email = $request->getPost('email');
$islegal = $request->getPost('islegal');
$user = new Core_Models_User(array(
'user_name' => $username,
'password' => $password,
'full_name' => $fullname,
'email' => $email,
'is_active' => 0,
'created_date' => date('Y-m-d H:i:s'),
'logged_in_date' => null,
'is_online' => 0,
'role_id' => 2,
'islegal' => $islegal,
));
$id = $userDao->add($user);
$templateDao = XXX_Model_Dao_Factory::getInstance()->setModule('mail')->getTemplateDao();
$templateDao->setDbConnection($conn);
$template = $templateDao->getByName(Mail_Models_Template::TEMPLATE_ACTIVATE_CONTRIBUTOR);
if ($template == null) {
$message = sprintf($this->view->translator('auth_mail_template_not_found'), Mail_Models_Template::TEMPLATE_ACTIVATE_CONTRIBUTOR);
throw new Exception($message);
}
$search = array(Mail_Models_Mail::MAIL_VARIABLE_EMAIL, Mail_Models_Mail::MAIL_VARIABLE_USERNAME);
$replace = array($user->email, $user->user_name);
$subject = str_replace($search, $replace, $template->subject);
$content = str_replace($search, $replace, $template->body);
/**
* Replace the reset password link
* #TODO: Add security key?
*/
$encodedLink = array(
'email' => $email,
'user_name' => $username,
);
$encodedLink = base64_encode(urlencode(Zend_Json::encode($encodedLink)));
$link = $this->view->serverUrl() . $this->view->url(array('encoded_link' => $encodedLink), 'core_user_emailactivate');
$content = str_replace('%activate_link%', $link, $content);
/**
* Get mail transport instance
*/
$transport = Mail_Services_Mailer::getMailTransport();
$mail = new Zend_Mail();
$mail->setFrom($template->from_mail, $template->from_name)
->addTo($user->email, $user->user_name)
->setSubject($subject)
->setBodyHtml($content)
->send($transport);
if ($id > 0) {
$this->_helper->getHelper('FlashMessenger')
->addMessage($this->view->translator('user_join_success'));
$this->_redirect($this->view->serverUrl() . $this->view->url(array(), 'core_user_contribjoin'));
}
}
}
I have found the error. I somehow did not put the variable encoded_link into the .ini file for that module under routes.