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

Gift Order Mod

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 05-10-2007, 10:33 AM
  DreamCatcher's Avatar 
DreamCatcher DreamCatcher is offline
 

Senior Member
  
Join Date: Mar 2004
Posts: 178
 

Post Gift Order Mod

This is a modificiation I made today which adds a small checkbox at checkout time which says "this is a gift do not show price on invoice". This mod will give the admin an invoice for the recipient which has no prices on it and it uses the customer notes box as a "gift message" area while still allowing the customer to view an invoice with price information on it.

I did this mod on 4.1.7 Pro. Your table names may vary so please make sure you know your database structure before tinkering. I take no responsibility for either one of us being a jackass and messing your site up so backup all your html and database before using this mod.

First we need to create a gift indicator field in database. This is the value of the check box a checkout. You can use MyPhpAdmin and enter the SQL below or go into your admin section->patch uprade area and enter this in the SQL query box

Code:
ALTER TABLE `xcart_orders` ADD `isgift` CHAR( 1 ) DEFAULT '0' NOT NULL


Now we add the language for the word "gift" and the text the customer sees next to the check box. Just as the SQL above you can put this sql into mysql admin or into a mysql console or the patch sql box in the upgrade area of your admin console.

Code:
INSERT INTO `xcart_languages` ( `code` , `name` , `value` , `topic` ) VALUES ( 'US', 'lbl_customer_isgift', 'Do not include invoice, this order a gift.', 'Labels' ); INSERT INTO `xcart_languages` ( `code` , `name` , `value` , `topic` ) VALUES ( 'US', 'lbl_gift', 'Gift' );


Now we add the gift check box to checkout area for the customer to select before submitting their order.

OPEN customer/main/checkout_notes.tpl


FIND
Quote:
<table cellspacing="0" cellpadding="2">
<tr valign="top">


CHANGE TO
Quote:
<table cellspacing="0" cellpadding="2">

<tr valign="top">
<td colspan=2>{$lng.lbl_customer_isgift}</td>
</td>
<td valign="bottom">
<input type="checkbox" name="IsGift" value="1"> {$lng.lbl_yes}
<BR><BR>
</td>
</tr>

<tr valign="top">

Save and close customer/main/checkout_notes.tpl



OPEN include/func/func.order.php


FIND
Quote:

$save_info = $userinfo;

ADD ABOVE IT
Quote:

## error checking on isgift check box. 1 = is gift = not gift no other values accepted
$isgift = ($_POST['IsGift'] ==1)?1:0;


Now add in the new field to the SQL insert (write it to the database)
FIND
Quote:
#
# Insert into orders
#
$insert_data = array (
'login' => addslashes($userinfo['login']),


CHANGE TO
Quote:

#
# Insert into orders
#
$insert_data = array (
'isgift'=>$isgift,
'login' => addslashes($userinfo['login']),

SAVE and CLOSE include/func/func.order.php


Now we add in a line which tells the invoice to show an invoice for a gift order that does not have prices listed but show one with prices to the customer when they order.

OPEN skin1/mail/html/order_invoice.tpl


FIND
Quote:
{include file="mail/html/order_data.tpl"}

REPLACE WITH

Quote:

{if $order.isgift eq '1' and $smarty.get.mode eq 'invoice'}
{include file="mail/html/order_data_gift.tpl"}
{else}
{include file="mail/html/order_data.tpl"}
{/if}



FIND
Quote:

<tr>
<td align="center"><font style="FONT-SIZE: 14px; FONT-WEIGHT: bold;">{$lng.lbl_customer_notes}</font></td>
</tr>

REPLACE WITH
Quote:
<tr>
{if $order.isgift eq '1'}
<td align="center"><font style="FONT-SIZE: 14px; FONT-WEIGHT: bold;">{$lng.lbl_gift_message}</font></td>
{else}
<td align="center"><font style="FONT-SIZE: 14px; FONT-WEIGHT: bold;">{$lng.lbl_customer_notes}</font></td>
{/if}
</tr>

SAVE and CLOSE skin1/mail/html/order_invoice.tpl



Assign $_GET['mode'] to $mode so we can access it in the invoice template

At this point you have a few choices... You can take the file below which is skin1/mail/html/order_data_gift.tpl and save it to your server and hope I got it right. Or you can create your own file for the gift invoice.

skin1/mail/html/order_data_gift.tpl
Quote:
{* $Id: order_data.tpl,v 1.29.2.6 2007/03/26 06:15:12 max Exp $ *}
<table cellspacing="0" cellpadding="0" width="100%" border="0">

<tr>
<td align="center"><font style="FONT-SIZE: 14px; FONT-WEIGHT: bold;">{$lng.lbl_products_ordered}</font></td>
</tr>

</table>

<table cellspacing="0" cellpadding="3" width="100%" border="1">

<tr>
<th width="60" bgcolor="#cccccc">{$lng.lbl_sku}</th>
<th bgcolor="#cccccc">{$lng.lbl_product}</th>
{if $order.extra.tax_info.display_cart_products_tax_ra tes eq "Y" and $_userinfo.tax_exempt ne "Y"}
<th nowrap="nowrap" width="100" bgcolor="#cccccc">{if $order.extra.tax_info.product_tax_name ne ""}{$order.extra.tax_info.product_tax_name}{else}{ $lng.lbl_tax}{/if}</th>
{/if}
<th nowrap="nowrap" width="100" bgcolor="#cccccc" align="center">{$lng.lbl_item_price}</th>
<th width="60" bgcolor="#cccccc">{$lng.lbl_quantity}</th>
<th width="60" bgcolor="#cccccc">{$lng.lbl_total}<br /><img height="1" src="{$ImagesDir}/spacer.gif" width="50" border="0" alt="" /></th>
</tr>

{foreach from=$products item=product}
<tr>
<td align="center">{$product.productcode}</td>
<td><font style="FONT-SIZE: 11px">{$product.product}</font>
{if $product.product_options ne '' && $active_modules.Product_Options}
<table>

<tr>
<td valign="top"><b>{$lng.lbl_options}:</b></td>
<td>{include file="modules/Product_Options/display_options.tpl" options=$product.product_options options_txt=$product.product_options_txt force_product_options_txt=$product.force_product_o ptions_txt}</td>
</tr>

</table>
{/if}
{if $active_modules.Egoods and $product.download_key and ($order.status eq "P" or $order.status eq "C")}
<br />
<a href="{$catalogs.customer}/download.php?id={$product.download_key}" class="SmallNote" target="_blank">{$lng.lbl_download}</a>
{/if}
</td>
{if $order.extra.tax_info.display_cart_products_tax_ra tes eq "Y" and $_userinfo.tax_exempt ne "Y"}
<td align="center">
{foreach from=$product.extra_data.taxes key=tax_name item=tax}
{if $tax.tax_value gt 0}
{if $order.extra.tax_info.product_tax_name eq ""}{$tax.tax_display_name} {/if}
{if $tax.rate_type eq "%"}{$tax.rate_value|formatprice:false:false:3}%{e lse}{include file="currency.tpl" value=$tax.rate_value}{/if}<br />
{/if}
{/foreach}
</td>
{/if}
<td align="right" nowrap="nowrap">{$lng.lbl_gift}&nbsp;&nbsp;</td>
<td align="center">{$product.amount}</td>
<td align="right" nowrap="nowrap">{$lng.lbl_gift} </td>
</tr>
{/foreach}

{if $giftcerts ne ''}
{foreach from=$giftcerts item=gc}
<tr>
<td>&nbsp;</td>
<td nowrap="nowrap">
{$lng.lbl_gift_certificate}: {$gc.gcid}<br />
<div style="padding-left: 10px; white-space: nowrap;">
{if $gc.send_via eq "P"}
{$lng.lbl_gc_send_via_postal_mail}<br />
{$lng.lbl_mail_address}: {$gc.recipient_firstname} {$gc.recipient_lastname}<br />
{$gc.recipient_address}, {$gc.recipient_city},<br />
{if $gc.recipient_countyname ne ''}{$gc.recipient_countyname} {/if}{$gc.recipient_state} {$gc.recipient_country}, {$gc.recipient_zipcode}<br />
{$lng.lbl_phone}: {$gc.recipient_phone}
{else}
{$lng.lbl_recipient_email}: {$gc.recipient_email}
{/if}
</div>
</td>
{if $order.extra.tax_info.display_cart_products_tax_ra tes eq "Y" and $_userinfo.tax_exempt ne "Y"}
<td align="center">&nbsp;-&nbsp;</td>
{/if}
<td align="right" nowrap="nowrap">{include file="currency.tpl" value=$gc.amount}&nbsp;&nbsp;</td>
<td align="center">1</td>
<td align="right" nowrap="nowrap">{include file="currency.tpl" value=$gc.amount}&nbsp;&nbsp;</td>
</tr>
{/foreach}
{/if}

</table>
<table cellspacing="0" cellpadding="0" width="100%" border="0">




</table>


{if $order.extra.special_bonuses ne ""}
{include file="mail/html/special_offers_order_bonuses.tpl" bonuses=$order.extra.special_bonuses}
{/if}




I'd appreciate your feedback. I would appreicate it that if you use this mod and you create custom gift invoices that you please share them with this thread for the betterment of the x-cart community.

the three attached photos are of

#1 Checkbox at time of checkout
#2 Invoice from cusomer perspective with prices
#3 invoice from fulfillment staff/ admin with no prices

By all means this is a quick hack for me. I am sure it can be done better and the order_data_gift.tpl above is by no means perfect.

-Todd
Attached Thumbnails
Click image for larger version

Name:	giftorder-cart.jpg
Views:	381
Size:	47.3 KB
ID:	373  Click image for larger version

Name:	giftorder-invoice.jpg
Views:	371
Size:	44.9 KB
ID:	374  Click image for larger version

Name:	giftorder-invoice-cust.jpg
Views:	375
Size:	54.8 KB
ID:	375  
Reply With Quote
  #2  
Old 05-10-2007, 10:46 AM
 
Jerrad Jerrad is offline
 

X-Adept
  
Join Date: Nov 2004
Location: The Netherlands
Posts: 484
 

Default Re: Gift Order Mod

Thanks for this very usefull mod, but do you think that it also will work for version 4.0.X or are there to many differences?

Thanks!
__________________
X-Cart 4.0.12
Heavy modified with paid, free and forum mods.
PHP 5.2.5 | MYSQL 5.0.51a
Reply With Quote
  #3  
Old 05-10-2007, 10:50 AM
  DreamCatcher's Avatar 
DreamCatcher DreamCatcher is offline
 

Senior Member
  
Join Date: Mar 2004
Posts: 178
 

Default Re: Gift Order Mod

I have added some screen caps of the different changes. I am not sure if it will work in 4.0 Jerrad but in all honesty the changes are really minor. I am sure someone better versed in x-cart can give it a look over and tell you for sure.

-Todd
Reply With Quote
  #4  
Old 05-10-2007, 10:55 AM
 
Jerrad Jerrad is offline
 

X-Adept
  
Join Date: Nov 2004
Location: The Netherlands
Posts: 484
 

Default Re: Gift Order Mod

Thanks for the quick reply DreamCatcher.
The screen caps do look good and I surely will put this mod on my to-do-list...
__________________
X-Cart 4.0.12
Heavy modified with paid, free and forum mods.
PHP 5.2.5 | MYSQL 5.0.51a
Reply With Quote
  #5  
Old 05-10-2007, 01:30 PM
  DreamCatcher's Avatar 
DreamCatcher DreamCatcher is offline
 

Senior Member
  
Join Date: Mar 2004
Posts: 178
 

Default Re: Gift Order Mod

I just updated the code to use

{if $order.isgift eq '1' and $smarty.get.mode eq 'invoice'}

instead of assigning the $_GET['mode'] to a variable. It removes the need to edit admin/order.php

-Todd
Reply With Quote
  #6  
Old 05-10-2007, 05:45 PM
 
Asiaplay Asiaplay is offline
 

X-Wizard
  
Join Date: Oct 2005
Posts: 1,242
 

Default Re: Gift Order Mod

Hi Todd (alias DreamCatcher),

Thanks for sharing this great mod - I do appreciate!!!... it really was something important that has been missing from X-Cart until now.
I just hope the customs guys are nice enough to let "gifts" through - think they should do.

Cheers & thanks again, Asiaplay...
__________________
X-Cart Gold version 4.1.9
(plus built in X-Cart bugs!)
Reply With Quote
  #7  
Old 05-10-2007, 06:12 PM
  DreamCatcher's Avatar 
DreamCatcher DreamCatcher is offline
 

Senior Member
  
Join Date: Mar 2004
Posts: 178
 

Default Re: Gift Order Mod

It's my pleasure Asiaplay, thank you for the support.

I have brought up a request for this mod in the past and had my fingers crossed that the folks at x-cart would have the forsight to add it into 4.1.7. I was shocked at how simple the actual modification was and I hope that they take my lead if they aren't wortking on it already and add it in to a subsequent release with some additional bells and whistles.

X-cart staff you can use my code for some store credit toward add-ons, licenses etc
Reply With Quote
  #8  
Old 01-03-2008, 06:31 PM
 
telimon telimon is offline
 

Advanced Member
  
Join Date: Jun 2007
Posts: 93
 

Default Re: Gift Order Mod

Thanks for this great mod. Was easy to do and should be very useful! Not sure if you can help me with one thing though. In creating a modified invoice, I want to select from one of two messages at the botom on the invoice depending on whether it is being used as a gift or not. For some reason I'm not able to get this to work. Do you see any obvious flaw in the following?
I placed the following right after the closing {/if} from {if $order.customer_notes ne ""} in the order_invoice.tpl. Only the else sems to be is working. Just wondering if anyone could see what's wrong.

{if $order.isgift eq '1'}
<tr>

<td align="center"><br /><br /><font style="FONT-SIZE:12px">{$lng.txt_thank_you_for_gift_purchase}< /font>
{if $donation.name neq ''}
<br /><font style="FONT-SIZE:12px">{include file="currency.tpl" value=$donation.amount assign="donation_amount"}
{$lng.lbl_donated_to_gift|substitute:amount:$donat ion_amount:partner:$donation.name}</font>{/if}
{* jas End *}</td>
{else}
<td align="center"><br /><br /><font style="FONT-SIZE:12px">{$lng.txt_thank_you_for_purchase}</font>
{* DBB SD Start *}{if $donation.name neq ''}
<br /><font style="FONT-SIZE:12px">{include file="currency.tpl" value=$donation.amount assign="donation_amount"}
{$lng.lbl_donated_to|substitute:amount:$donation_a mount:partner:$donation.name}</font>{/if}
{* DBB SD End *}</td>
</tr>
{/if}
__________________
4.710
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


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 01:26 PM.

   

 
X-Cart forums © 2001-2020