User Tools

Site Tools


zencartmods

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
zencartmods [2011/04/25 23:07]
ladyada
— (current)
Line 1: Line 1:
-====== Improving Coupon Reports ====== 
-Want to know how much was '​saved'​ by your customers by using a discount coupon? Here is a mod for v1.38 that will add it in the Admin coupon report. Enjoy :) 
- 
-in **admin/​coupon_admin.php** change lines 455+ to the following, adding the two statements marked "START MOD" and "END MOD" 
- 
-<code php> 
-<?php 
-    $heading = array(); 
-    $contents = array(); 
-      $coupon_desc = $db->​Execute("​select coupon_name 
-                                   from " . TABLE_COUPONS_DESCRIPTION . " 
-                                   where coupon_id = '"​ . $_GET['​cid'​] . "'​ 
-                                   and language_id = '"​ . $_SESSION['​languages_id'​] . "'"​);​ 
-      $count_customers = $db->​Execute("​select * from " . TABLE_COUPON_REDEEM_TRACK . " 
-                                       where coupon_id = '"​ . $_GET['​cid'​] . "'​ 
-                                       and customer_id = '"​ . $cInfo->​customer_id . "'"​);​ 
-// START MOD 
-      $coupon_saved = $db->​Execute("​SELECT sum(value) as saved FROM " . TABLE_COUPON_REDEEM_TRACK . ", " . TABLE_ORDERS_TOTAL . " WHERE coupon_id = " . $_GET['​cid'​] . " AND orders_id = order_id AND class = '​ot_coupon'"​);​ 
-// END MOD 
-      $heading[] = array('​text'​ => '<​b>​['​ . $_GET['​cid'​] . '​]'​ . COUPON_NAME . ' ' . $coupon_desc->​fields['​coupon_name'​] . '</​b>'​);​ 
-      $contents[] = array('​text'​ => '<​b>'​ . TEXT_REDEMPTIONS . '</​b>'​);​ 
-//      $contents[] = array('​text'​ => TEXT_REDEMPTIONS_TOTAL . '​='​ . $cc_list->​RecordCount());​ 
-      $contents[] = array('​text'​ => TEXT_REDEMPTIONS_TOTAL . '​='​ . $cc_query_numrows);​ 
-      $contents[] = array('​text'​ => TEXT_REDEMPTIONS_CUSTOMER . '​='​ . $count_customers->​RecordCount());​ 
-// START MOD 
-      $contents[] = array('​text'​ => TEXT_REDEMPTIONS_SAVED . '​='​ . $coupon_saved->​fields['​saved'​]);​ 
-// END MOD 
-      $contents[] = array('​text'​ => ''​);​ 
-?> 
-</​code>​ 
- 
-====== Allowing + in email ====== 
-Line 548 of includes/​functions/​functions_email.php 
-<​code>​ 
-$valid_email_pattern = '​^[a-z0-9]+[a-z0-9_\.\'​\-\+]*@[a-z0-9]+[a-z0-9\.\-]*\.(([a-z]{2,​6})|([0-9]{1,​3}))$';​ 
-</​code>​ 
- 
- 
-====== Adding a barcode to invoices ====== 
- 
-{{  :​zencartmods:​barcoded.jpg| ​ }} 
- 
-Barcodes on invoices can be very handy if you have an automated shipping system. This mod will show you how to do that with only one line of added code to **invoice.php**. You'll need a barcode generator, this public domain code snipped by Charles J. Scheffold is ten years old and works great :) 
- 
-Download {{:​barcode.php.zip|barcode.php.zip}} and uncompress it, upload the barcode.php file to your **zencart/​admin** directory 
- 
-Then we can call this code to make a barcode image wherever we want! Open up **admin/​invoice.php** and stick this line where ever you want the barcode 
- 
-We suggest: 
- 
-find line 48 of invoice.php 
-<​code>​ 
-<!-- body_text //--> 
-</​code>​ 
- 
-and replace it with: 
-<code php> 
-<!-- body_text //--> 
-<?php echo '<​img src="​barcode.php?​barcode='​ . $oID . '&​width=250&​height=50"​ />';​ ?>; 
-</​code>​ 
- 
-====== Hiding inventory numbers ====== 
- 
-You can simplify your inventory display so that over a certain qty, the cart just says "In Stock" 
- 
-{{:​zencartmods:​qtyover100.gif|}} 
- 
-In this example, we use 100 as the limit under which we display the quantity but of course you can change that pretty easily in the **define** to whatever you wish 
- 
-==== New Files ==== 
- 
-Create a defines page, call it anything (we called it **products_quantities_mods.php**) and put it in **/​includes/​extra_datafiles/​** 
- 
-<code php> 
-<?php 
-define(STOCK_SHOW_LIMIT,​ 100); 
-define(STOCK_OFFSET,​ 3); 
-define(STOCK_TEXT_IN_STOCK,​ 'IN STOCK'​);​ 
-define(STOCK_TEXT_QUANTITY_IN_STOCK,​ 'IN STOCK'​);​ 
-define(STOCK_TEXT_OUT_OF_STOCK,​ 'OUT OF STOCK'​);​ 
-?> 
-</​code>​ 
- 
-This should be the entire file.  
- 
-NB: Make sure there isnt any white space before the '<?​php'​ or after the '?>'​. Any whitespace output there will cause php to send headers, which you don't want to do yet.  
- 
-==== Change Settings ==== 
- 
-Make sure that the normal method for displaying products quantity is disabled. 
- 
-Go to **Admin>​Catalog>​Product Types>​Products( General )>Edit Layout** 
- 
-and set **Show Quantity in Stock** to false. (Do this for **Products (General)**,​ and any other types of products you use in the store) 
- 
-This will remove the quantity display from everywhere on the site. This tutorial will cover adding it back into the individual products page and the products listing page. If you'd like to keep this feature enabled, please see the optional instructions at the bottom. ​ 
- 
-==== Show Quantity up to 100 ==== 
- 
-Files to modify: 
- 
-**/​includes/​templates/​YOUR_TEMPLATE/​tpl_product_info_display.php \\ 
-/​includes/​modules/​product_listing.php \\ 
-includes/​templates/​YOUR_TEMPLATE/​templates/​tpl_modules_products_all_listing.php** 
- 
-Paste this new code into **tpl_product_info_display.php** anywhere you'd like -- we recommend right below the price (line 75) 
-<code php> 
-<div class="​availability">​ 
-<?php 
-if($products_quantity > STOCK_SHOW_LIMIT)  
-  echo STOCK_TEXT_IN_STOCK;​ 
-elseif($products_quantity > 0)  
-  echo $products_quantity . ' ' . STOCK_TEXT_QUANTITY_IN_STOCK;​ 
-else  
-  echo STOCK_TEXT_OUT_OF_STOCK;​ 
-?>      ​ 
-</​div>​ 
-</​code>​ 
- 
-in **includes/​modules/​product_listing.php** 
- 
-find (lines 148-151) 
-<code php> 
-case '​PRODUCT_LIST_QUANTITY':​ 
-        $lc_align = '​right';​ 
-        $lc_text = $listing->​fields['​products_quantity'​];​ 
-</​code>​ 
-and replace them with  
-<code php> 
-case '​PRODUCT_LIST_QUANTITY':​ 
-        $lc_align = '​right';​ 
- if($listing->​fields['​products_quantity'​] > STOCK_SHOW_LIMIT) 
-          $lc_text = STOCK_TEXT_IN_STOCK;​ 
- elseif($listing->​fields['​products_quantity'​] > 0) 
-          $lc_text = $listing->​fields['​products_quantity'​] . ' ' . STOCK_TEXT_QUANTITY_IN_STOCK;​ 
-        else 
-          $lc_text = STOCK_TEXT_OUT_OF_STOCK;​ 
-</​code>​ 
- 
- 
-in **includes/​templates/​YOUR_TEMPLATE/​templates/​tpl_modules_products_all_listing.php** 
- 
-find (line 59) 
-<code php> 
-$display_products_quantity = TEXT_PRODUCTS_QUANTITY . $products_all->​fields['​products_quantity'​] . str_repeat('<​br clear="​all"​ />',​ substr(PRODUCT_ALL_LIST_QUANTITY,​ 3, 1)); 
-</​code>​ 
-and replace with  
-<code php> 
-          if ($products_all->​fields['​products_quantity'​] > STOCK_SHOW_LIMIT) 
-            $display_products_quantity = STOCK_TEXT_IN_STOCK;​ 
-          elseif($products_all->​fields['​products_quantity'​] > 0) 
-            $display_products_quantity = $products_all->​fields['​products_quantity'​] . ' ' . STOCK_TEXT_IN_STOCK;​ 
-          else 
-            $display_products_quantity = STOCK_TEXT_OUT_OF_STOCK;​ 
-          $display_products_quantity .= str_repeat('<​br clear="​all"​ />',​ substr(PRODUCT_ALL_LIST_QUANTITY,​ 3, 1)); 
-</​code>​ 
- 
-==== Optional Stuff ==== 
- 
-If you would rather not set the "Show Products Quantity"​ option to false then you'll need to make the following mods as well to each of the following files: 
- 
-Modified Files: \\ 
-**includes/​templates/​YOUR_TEMPLATE/​templates/​tpl_modules_products_all_listing.php \\ 
-includes/​templates/​YOUR_TEMPLATE/​templates/​tpl_modules_products_featured_listing.php \\ 
-includes/​templates/​YOUR_TEMPLATE/​templates/​tpl_modules_products_new_listing.php** \\ 
- 
-For the Stock Limit: 
- 
-in **includes/​templates/​YOUR_TEMPLATE/​templates/​tpl_modules_products_all_listing.php** 
- 
-find (line59) 
-<code php> 
-$display_products_quantity = TEXT_PRODUCTS_QUANTITY . $products_all->​fields['​products_quantity'​] . str_repeat('<​br clear="​all"​ />',​ substr(PRODUCT_ALL_LIST_QUANTITY,​ 3, 1)); 
-</​code>​ 
-and replace with  
-<code php> 
-          if ($products_all->​fields['​products_quantity'​] > STOCK_SHOW_LIMIT) 
-            $display_products_quantity = STOCK_TEXT_IN_STOCK;​ 
-          elseif($products_all->​fields['​products_quantity'​] > 0) 
-            $display_products_quantity = $products_all->​fields['​products_quantity'​] . ' ' . STOCK_TEXT_IN_STOCK;​ 
-          else 
-            $display_products_quantity = STOCK_TEXT_OUT_OF_STOCK;​ 
-          $display_products_quantity .= str_repeat('<​br clear="​all"​ />',​ substr(PRODUCT_ALL_LIST_QUANTITY,​ 3, 1)); 
-</​code>​ 
- 
-The changes for **tpl_modules_products_featured_listing.php** and **tpl_modules_products_new_listing.php** are identical except that the variable **$products_all** should be replaced with **$featured_products** and **$products_new** respectively. 
- 
-====== Stashing inventory ====== 
- 
-This mod will let you '​save'​ 3 (or whatever #) pieces of inventory of each item. So if the true inventory is 50 pieces, the store will act like there is only 47. This will let you keep a stash around in case you need extras to replace customer'​s damaged or lost packages, or if your inventory is off by a few pieces. 
- 
-For example, we have 83 Mintyboosts in stock: 
- 
-{{:​zencartmods:​trueinventory.gif|}} 
- 
-But the cart displays only 80: 
- 
- ​{{:​zencartmods:​stashedinventory.gif|}} 
- 
- 
-===== New Files ===== 
- 
-We'll be using the same file as the "Show IN STOCK over 100 quantity"​ mod above 
- 
-===== Change Settings ===== 
- 
-Change the same settings as the "Show IN STOCK over 100 quantity"​ mod above 
- 
-===== Code changes ===== 
- 
-Files changed: **/​includes/​functions/​functions_lookups.php \\ 
-/​includes/​functions/​functions_general.php \\ 
-/​includes/​modules/​product_listing.php \\ 
-/​includes/​modules/​pages/​product_info/​main_template_vars.php** 
- 
-in **/​includes/​functions/​functions_lookups.php** 
- 
-find (line 172) 
-<​code>​ 
-    return $stock_values->​fields['​products_quantity'​];​ 
-</​code>​ 
-and replace it with 
-<code php> 
-    return $stock_values->​fields['​products_quantity'​] - STOCK_OFFSET;​ 
-</​code>​ 
- 
-in **/​includes/​functions/​functions_general.php** 
- 
-find (line 130) 
-<code php> 
-$button_check = $db->​Execute("​select product_is_call,​ products_quantity from " . TABLE_PRODUCTS . " where products_id = '"​ . (int)$product_id . "'"​);​ 
-</​code>​ 
- 
-and add a line below it so that it is looks like: 
-<code php> 
-$button_check = $db->​Execute("​select product_is_call,​ products_quantity from " . TABLE_PRODUCTS . " where products_id = '"​ . (int)$product_id . "'"​);​ 
-$button_check->​fields['​products_quantity'​] = zen_get_products_stock($product_id);​ 
-</​code>​ 
- 
- 
-in **/​includes/​modules/​product_info.php** 
- 
-find (line 77) 
-<code php> 
-  while (!$listing->​EOF) { 
-    $rows++; 
-</​code>​ 
-and replace with 
-<code php> 
-  while (!$listing->​EOF) { 
-    $rows++; 
-    $listing->​fields['​products_quantity'​] = zen_get_products_stock($listing->​fields['​products_id'​]);​ 
-</​code>​ 
- 
- 
-in **/​includes/​modules/​pages/​product_info/​main_template_vars.php** 
- 
-find (line 115) 
-<code php> 
-$products_quantity = $product_info->​fields['​products_quantity'​];​ 
-</​code>​ 
- 
-and replace it with  
-<code php> 
-  // Stock Offset Mod 
-  $products_quantity = zen_get_products_stock($product_id);​ 
-</​code>​ 
- 
-===== Adding invoice images ===== 
- 
-Adding images to invoices will make shipping easier, reduce mistakes and help customers identify what the heck it is that's in that box. Since zen cart already has images for all items, its really easy to add 
- 
-{{:​zencartmods:​invoiceimage.gif|}} 
- 
- 
-By default, it will use the thumbnails used in the shop navication. Optionally, you can make a folder in images/ called /invoice to override the images in case you'd like a different image on the invoice than shows up on the website. ​ 
- 
-=== admin/​invoice.php === 
- 
-Find (line 146) 
-<code html> 
-      <tr class="​dataTableHeadingRow">​ 
-</​code>​ 
-replace with  
-<code html> 
-      <tr class="​dataTableHeadingRow">​ 
-<td width="​120px"></​td>​ 
-</​code>​ 
- 
-Find (line 156) 
-<code php> 
-    for ($i = 0, $n = sizeof($order->​products);​ $i < $n; $i++) { 
-</​code>​ 
-replace with  
-<code php> 
-    for ($i = 0, $n = sizeof($order->​products);​ $i < $n; $i++) { 
-      $itemimage = $db->​Execute("​select products_image from " . TABLE_PRODUCTS . " where products_id = '"​ . (int)$order->​products[$i]['​id'​] . "'"​);​ 
-      $invoice_image = $itemimage->​fields['​products_image'​];​ 
-      if(file_exists("​../​images/​invoice/"​ . $invoice_image)) // this part is optional 
-           ​{ ​                                                // this will look for the same filename in 
-             ​$invoice_image = "​invoice/"​ . $invoice_image; ​  // /​images/​invoice and use that instead 
-           ​} ​                                                // ​ 
-</​code>​ 
- 
-Find (line 164) 
-<code php> 
-      echo ' ​     <tr class="​dataTableRow">'​ . "​\n"​ . 
-           ' ​       <td class="​dataTableContent"​ valign="​top"​ align="​right">'​ . $order->​products[$i]['​qty'​] . '&​nbsp;​x</​td>'​ . "​\n"​ . 
-           ' ​       <td class="​dataTableContent"​ valign="​top">'​ . $order->​products[$i]['​name'​];​ 
-</​code>​ 
-replace with  
-<code php> 
-     ​echo ​ ' ​     <tr class="​dataTableRow">'​ . "​\n"​ . '<​td class="​dataTableContent" ​ valign="​center">​(&​nbsp;​)&​nbsp;<​img width="​100"​ src="/​images/'​ . $invoice_image . '"​ /></​td>'​ . 
-           ' ​       <td class="​dataTableContent"​ valign="​top"​ align="​right">&​nbsp;'​ . $order->​products[$i]['​qty'​] . '&​nbsp;​x</​td>'​ . "​\n"​ . 
-           ' ​       <td class="​dataTableContent"​ valign="​top">'​ . $order->​products[$i]['​name'​];​ 
-</​code>​ 
- 
  
/home/ladyada/public_html/wiki/data/attic/zencartmods.1303772827.txt.gz · Last modified: 2016/01/28 18:05 (external edit)