Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Custom Order Status inc Email To Customer and Stock Correction X-Cart 4.5.x
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #1  
Old 08-21-2012, 03:34 AM
  Raptor's Avatar 
Raptor Raptor is offline
 

Senior Member
  
Join Date: Jan 2006
Posts: 125
 

Thumbs up Custom Order Status inc Email To Customer and Stock Correction X-Cart 4.5.x

JULY 10 2014: UPDATED TO LATEST 4.6.2 and above - All functions tested 100%

Like many others I require several different custom order status and would also like the customer to be emailed on change of status, and also the option to put the product back in stock. A perfect example of this is Refunds.

After doing some research with regards to older versions I was able to get it working perfectly on my own 4.6.2 (Thanks to Jon & imexhouse in THIS THREAD) and thanks to Thomasb134 in THIS POST)

For this example I am going to add a 'Refunded' order status. Of course you can change to whatever you require. I have also hardcoded the Order Status name as opposed to using a label.

Open skin/common_files/main/order_status.tpl

FIND (Around Line 15):

Code:
<option value="I"{if $status eq "I"} selected="selected"{/if}>{$lng.lbl_not_finished}</option>

AFTER ADD:

Code:
<option value="R"{if $status eq "R"} selected="selected"{/if}>Refunded</option>

FIND (Around Line 27):

Code:
{if $status eq "I"} {$lng.lbl_not_finished}

AFTER ADD:

Code:
{elseif $status eq "R"} Refunded



Open include/func/func.order.php

FIND (Around Line 1666):

Code:
$allowed_order_status = 'IQPBDFCA';

CHANGE TO:

Code:
$allowed_order_status = 'IRQPBDFCA';


FIND (Around Line 1689):

Code:
$send_notification = false; if ( $status == 'P'


CHANGE TO:

Code:
$send_notification = false; // Start Custom Refund Function // Send email notification to user if ($status == "R" && $order['status'] != "R") { $userinfo = $order_data['userinfo']; $mail_smarty->assign('customer',$userinfo); $to_customer = ($userinfo['language']?$userinfo['language']:$config['default_customer_language']); $mail_smarty->assign("products", func_translate_products($order_data["products"], $to_customer)); $mail_smarty->assign("order", $order); func_send_mail($userinfo['email'], "mail/order_refunded_subj.tpl", "mail/html/order_customer_refunded.tpl", $config['Company']['orders_department'], false); } // End Custom Refund Function // Custom Order Status Code, Return Cancelled products to stock if ( $status == "R" && $order['status'] != 'R' && $order['status'] != 'F' && $order['status'] != 'D' ) { func_update_quantity($order_data['products'],true); } elseif ( $status == 'P'

Find this:

Code:
// Decrease quantity in stock when 'declined' or 'failed' order is became 'completed', 'processed' or 'queued' if ( $status != $order['status'] && in_array($order['status'], array('D', 'F')) && in_array($status, array('C','P','Q','I','B','X'))

change to

Code:
// Decrease quantity in stock when 'declined' or 'failed' or 'refunded' order is became 'completed', 'processed' or 'queued' if ( $status != $order['status'] && in_array($order['status'], array('D', 'F', 'R')) && in_array($status, array('C','P','Q','I','B','X'))

FIND:
Code:
} elseif ( in_array($status, array('D','F')) && !in_array($order['status'], array('D', 'F'))

CHANGE TO:

Code:
} elseif ( in_array($status, array('D','F', 'R')) && !in_array($order['status'], array('D', 'F', 'R'))

FIND:

Code:
} elseif ( $status == 'D' && $order['status'] != 'D' && $order['status'] != 'F' ) {

CHANGE TO:
Code:
} elseif ( $status == 'D' && $order['status'] != 'D' && $order['status'] != 'F' && $order['status'] != 'R' ) {

FIND:
Code:
} elseif ( $status == 'F' && $order['status'] != 'F' && $order['status'] != 'D' ) {
CHANGE TO:
Code:
} elseif ( $status == 'F' && $order['status'] != 'F' && $order['status'] != 'D' && $order['status'] != 'R' ) {

FIND:
Code:
if (($status != 'D') && ($status != 'F')) return;

CHANGE TO:
Code:
if (($status != 'D') && ($status != 'F') && ($status != 'R')) return;


Open modules/Advanced_Order_Mangement/func.php

FIND (Around Line 391):

Code:
'I' => func_get_langvar_by_name('lbl_not_finished'),

ADD AFTER:

Code:
'R' => func_get_langvar_by_name('Refunded'),

Then you need to create the email templates and upload to:

skin/common_files/mail/html/order_customer_refunded.tpl
skin/common_files/mail/order_refunded.tpl
skin/common_files/mail/

Here are some example templates:

order_customer_refunded.tpl

Code:
{config_load file="$skin_config"} {include file="mail/html/mail_header.tpl"} <br /> <br />{include file="mail/salutation.tpl" title=$customer.title firstname=$customer.firstname lastname=$customer.lastname} <br /> <br />Your order <b>#{$order.orderid}</b> has been refunded. <br /><br /> {include file="mail/html/signature.tpl"}

order_refunded.tpl

Code:
{config_load file="$skin_config"} {include file="mail/mail_header.tpl"} {include file="mail/salutation.tpl" title=$order.title firstname=$order.firstname lastname=$order.lastname} Your order #{$order.orderid} has been refunded. {include file="mail/signature.tpl"}

order_refunded_subj.tpl

Code:
{$config.Company.company_name}: Your order #{$order.orderid} has been refunded


I have tested the above working 100% with v4.6.2 - I hope someone finds it as useful as I have

Greets to Phil @ www.xcartmods.co.uk
__________________
X-Cart Gold Plus v4.7.7
- ReBOOT Template
- Advanced Category Menus & Featured Categories
- Advanced Testimonials
- Advanced Upselling Products
- Abandoned Cart Reminder
- Shipworks

Designed By Phil Jones - Highly Recommended for all X-Cart Custom work
www.xcartmods.co.uk
Reply With Quote

The following 8 users thank Raptor for this useful post:
espresso (11-07-2014), jacob1978 (04-23-2013), PhilJ (08-21-2012), philrisk (08-21-2012), photo (08-21-2012), Steel (09-19-2014), totaltec (08-21-2012), zone1creative (12-20-2016)
  #2  
Old 01-26-2013, 03:08 PM
  jcorneli's Avatar 
jcorneli jcorneli is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 74
 

Default Re: Custom Order Status inc Email To Customer and Stock Correction X-Cart 4.5.x

You are the man! This worked great on the first try.

I wanted to post to shout out to Phil as well.

Greets to Phil @ www.xcartmods.co.uk
__________________
www.usapolicesupply.com
v4.6.3

Xcartmods reBoot Template
WebsiteCM CDSEO Pro SEO
BCS Multipe Upselling Links
Firetank Feed Manager

BCS Product Importer Updater Pro
BCS Drop Shipper Pro
BCS Quote Request Module
BCS Printable Online Catalog
Reply With Quote
  #3  
Old 07-22-2013, 10:53 PM
  Raptor's Avatar 
Raptor Raptor is offline
 

Senior Member
  
Join Date: Jan 2006
Posts: 125
 

Default Re: Custom Order Status inc Email To Customer and Stock Correction X-Cart 4.5.x

Tested working with 4.6.2
__________________
X-Cart Gold Plus v4.7.7
- ReBOOT Template
- Advanced Category Menus & Featured Categories
- Advanced Testimonials
- Advanced Upselling Products
- Abandoned Cart Reminder
- Shipworks

Designed By Phil Jones - Highly Recommended for all X-Cart Custom work
www.xcartmods.co.uk
Reply With Quote
  #4  
Old 08-15-2013, 01:34 PM
  Raptor's Avatar 
Raptor Raptor is offline
 

Senior Member
  
Join Date: Jan 2006
Posts: 125
 

Default Re: Custom Order Status inc Email To Customer and Stock Correction X-Cart 4.5.x

Original post updated for 4.6.2
__________________
X-Cart Gold Plus v4.7.7
- ReBOOT Template
- Advanced Category Menus & Featured Categories
- Advanced Testimonials
- Advanced Upselling Products
- Abandoned Cart Reminder
- Shipworks

Designed By Phil Jones - Highly Recommended for all X-Cart Custom work
www.xcartmods.co.uk
Reply With Quote
  #5  
Old 08-15-2013, 01:52 PM
  Raptor's Avatar 
Raptor Raptor is offline
 

Senior Member
  
Join Date: Jan 2006
Posts: 125
 

Default Re: Custom Order Status inc Email To Customer and Stock Correction X-Cart 4.5.x

Original post updated for 4.6.2
__________________
X-Cart Gold Plus v4.7.7
- ReBOOT Template
- Advanced Category Menus & Featured Categories
- Advanced Testimonials
- Advanced Upselling Products
- Abandoned Cart Reminder
- Shipworks

Designed By Phil Jones - Highly Recommended for all X-Cart Custom work
www.xcartmods.co.uk
Reply With Quote
  #6  
Old 08-15-2013, 02:06 PM
  Raptor's Avatar 
Raptor Raptor is offline
 

Senior Member
  
Join Date: Jan 2006
Posts: 125
 

Default Re: Custom Order Status inc Email To Customer and Stock Correction X-Cart 4.5.x

Original post updated for 4.6.2
__________________
X-Cart Gold Plus v4.7.7
- ReBOOT Template
- Advanced Category Menus & Featured Categories
- Advanced Testimonials
- Advanced Upselling Products
- Abandoned Cart Reminder
- Shipworks

Designed By Phil Jones - Highly Recommended for all X-Cart Custom work
www.xcartmods.co.uk
Reply With Quote

The following user thanks Raptor for this useful post:
PhilJ (08-15-2013)
  #7  
Old 03-24-2014, 04:54 PM
 
Thomasb134 Thomasb134 is online now
 

X-Adept
  
Join Date: Apr 2007
Location: USA
Posts: 756
 

Default Re: Custom Order Status inc Email To Customer and Stock Correction X-Cart 4.5.x

I applied the Custom Status mod (including the inventory fix in post 6) and found inventory updates still did not work correctly. I made some changes and it now works fine in my V4.4.5 store. I'll share what I found in case others run into inventory accuracy issues like me.

I performed all the updates noted in this disussion. However, I had to modify some of the new code used in the /include/func/func.order.php as follows:

Find Original Code:
Code:
$send_notification = false; if ( $status == 'P'

Change to:
Code:
$send_notification = false; // Custom Order Status Code, Return Cancelled products to stock if ( $status == "R" && $order['status'] != 'R' && $order['status'] != 'F' && $order['status'] != 'D' ) { func_update_quantity($order_data['products'],true); } elseif ( $status == 'P'


I also had to add some extra code to accommodate some status changes that were missing in the original mod.
Find Original Code:
Code:
} elseif ( $status == 'D' && $order['status'] != 'D' && $order['status'] != 'F' ) {


Change to:
Code:
} elseif ( $status == 'D' && $order['status'] != 'D' && $order['status'] != 'F' && $order['status'] != 'R' ) {


Find Original Code:
Code:
} elseif ( $status == 'F' && $order['status'] != 'F' && $order['status'] != 'D' ) {

Change to:
Code:
} elseif ( $status == 'F' && $order['status'] != 'F' && $order['status'] != 'D' && $order['status'] != 'R' ) {

Many thanks to those that did all the hard work!
__________________
Thomas / USA
XCart V4.4.5 Gold
XCart Mobile V1.4.12
XCart X-PDF
XCart X-HotProducts
AlteredCart Checkout One (One Page Checkout)
BCSE Back In Stock
CFL Holiday Message
CFL System Message
Smack Digital (WebsiteCM) Remember Anon Carts
xcartmods Testimonials
Unix, PHP 7.0 (patched 5.4). Currently patching PHP 7.1
MySQL 5.6
Reply With Quote

The following user thanks Thomasb134 for this useful post:
Raptor (07-10-2014)
  #8  
Old 04-28-2014, 09:46 PM
 
xtech xtech is offline
 

X-Adept
  
Join Date: Jun 2010
Posts: 605
 

Default Re: Custom Order Status inc Email To Customer and Stock Correction X-Cart 4.5.x

How to bring this order status in order export pack also?
__________________
X-cart Platinum
4.6.1
Reboot template
Reply With Quote
  #9  
Old 06-21-2014, 03:46 PM
  DrQuietus's Avatar 
DrQuietus DrQuietus is offline
 

Advanced Member
  
Join Date: Dec 2005
Posts: 81
 

Default Re: Custom Order Status inc Email To Customer and Stock Correction X-Cart 4.5.x

Any idea why this change would make my admin/orders.php page go blank? It goes blank with changes from post #1 and/or the change from post #5. Version 4.6.1 with the reboot skin.
__________________
Dave Jones
dave@industrialwebworks.net
Mostly 4.7.2 - 4.7.5
Reply With Quote
  #10  
Old 06-21-2014, 05:17 PM
 
Thomasb134 Thomasb134 is online now
 

X-Adept
  
Join Date: Apr 2007
Location: USA
Posts: 756
 

Default Re: Custom Order Status inc Email To Customer and Stock Correction X-Cart 4.5.x

Check your php error logs. The line number that is causing the php problem will probably be noted in the log.
__________________
Thomas / USA
XCart V4.4.5 Gold
XCart Mobile V1.4.12
XCart X-PDF
XCart X-HotProducts
AlteredCart Checkout One (One Page Checkout)
BCSE Back In Stock
CFL Holiday Message
CFL System Message
Smack Digital (WebsiteCM) Remember Anon Carts
xcartmods Testimonials
Unix, PHP 7.0 (patched 5.4). Currently patching PHP 7.1
MySQL 5.6
Reply With Quote

The following user thanks Thomasb134 for this useful post:
DrQuietus (06-27-2014)
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:58 PM.

   

 
X-Cart forums © 2001-2018