SKU (scode) Coupon in Mals - Updated (v. 2.83 - 2.84)
This modification is designed for version 2.83-2.84 files only. If you want to use it on a 2.72 site, change the following in step 3:
range(1,15)
to:
range(1,5)
Note: As of April 2015, this modification will not work with Discount Tables, but only on Discount Coupons.
Mals gives you the option to create coupons that apply only to certain products. In the past, these coupons required the use of the "scode" variable in the Mals cart, but Pappashop.com uses that variable.
Mals has now updated the cart to allow an override 'sku' field for Discount Coupons. The following modification details an update that will allow you to add a discount checker by category or keyword. (Looking for the original mod?)
-
Open the order.php file in the /go/ folder.
-
Around line 489, find the code:
$gotolink .= "&scode=$scode";
-
Just under this code, add the following:
// CREATE SKU CODE FOR MALS DISCOUNTS $sku = ''; $skucode = 'SOMESKU'; $skuresult = mysql_query("SELECT Keywords, Category" .implode(", Category", range(1,15)) ." FROM " .SB_DB_PREFIX ."_items WHERE ID='$productid'", $dblink) or die ("Unable to create product sku. Try again later."); if (mysql_num_rows($skuresult) == 1) { $skurow = mysql_fetch_array($skuresult); } if (!empty($sku)) $gotolink .= "&sku=$sku"; // END SKU -
Change SOMESKU to whatever code you want to use as the sku value that will be passed through to the cart. (This does not have to be the same as your coupon code.) Change this value in the instructions that follow as well.
-
In that code you just added, just under the line:
$skurow = mysql_fetch_array($skuresult);
add one of the following:
-
If you want to discount only items in categories that have a particular keyword:
$skucats = array(); $skcatresult = mysql_query("SELECT ID FROM " .SB_DB_PREFIX ."_categories WHERE Keywords LIKE '%".$skucode."%'", $dblink); while ($skcatrow = mysql_fetch_array($skcatresult)) { $skucats[] = $skcatrow[ID]; } for($sk=1; $sk<=15; ++$sk) { if (in_array($skurow['Category'.$sk], $skucats)) { $sku = $skucode; break; } }And then in your categories, make sure the discounted categories have SOMESKU (or whatever you used for the sku value) in the keywords.
- OR -
-
If you want to discount only items that have a particular keyword:
// SHOW FOR ONLY SOME KEYWORDS if (str_replace($skucode, '', $skurow[Keywords]) != $skurow[Keywords]) $sku = $skucode;
And then in your products, make sure the discounted items have SOMESKU (or whatever you used for the sku value) in the keywords.
Need a particular item check (e.g. all items with prices greater than 20.00, or items without sale items, or items with the word 'diaper' in the name)? Contact us and we'll let you know if it's possible!
-
-
In Mals, select the discount coupons area:
Mals admin -> Cart setup -> Discounts -> Discount coupons
and enter the following:
- Coupon code: Create a coupon code if you want. (This does not have to be the same as the SKU.)
- Coupon's value: Add the amount or percentage of the coupon
- Minimum order, expires, etc. - add if desired
- Under 'This discount is applied to products with an SKU (scode) which':
- Select 'is equal to' in the drop down box.*
- Enter SOMESKU (or whatever you used for the sku value) in the box next to that.
- Click the 'Add coupon' button to create the coupon.
* If you want to use the SKU code to keep products from receiving a discount, select 'is not equal to' instead.
Important! If someone knows your SKU (or sees it in the URL when you add a discounted item to the cart), they can spoof the links and potentially add that SKU value to get discounts on other items. This would require a high level of understanding, and poses no more risk than a user changing prices in Mals, so it would be rare to see this happen. However, it's important that your client know that all cart details, including discounts, should be checked before items are shipped.