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/13 17:14]
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. 
/home/ladyada/public_html/wiki/data/attic/zencartmods.1302714874.txt.gz · Last modified: 2016/01/28 18:05 (external edit)