gdfwilliams Posted February 11, 2003 Posted February 11, 2003 I've searched the forum without much success for methods to hack the Discount Coupons contribution to include the option of Free Shipping. My site currently offers Free Shipping for orders over $100. As part of a promotion postcard mailing, I want to offer Free Shipping for orders over $25, but only to the group that receives the postcard (well, plus each of their 100 closest friends and neighbors who they just HAD to tell about this AMAZING offer ;)). (It's not a unique coupon per postcard. The same code will be printed on each.) Is this possible using the base Discount Coupons contribution? Though Linda's FreeShipper is included in the install, that is so that a user doesn't pay shipping on a product with weight 0 (i.e., a gift voucher). I suspect that the weight definition is where to focus: if $coupon=free_shipping, total_weight=0. Either way, it's today's project. I'll contribute my progress. Any suggestions? Thanks, Greg
mattice Posted February 11, 2003 Posted February 11, 2003 The most simple way will be to just slam in a text field that takes a code, transport it to checkout_confirmation.php. There you match your highly secret voucher code... if it is correct and order_total > 25 set shipping to zero 'manually'. i would not go to the trouble of converting Ians stuff, just make it an include and take it offline when your all out of neighbors. Mattice "Politics is the art of preventing people from taking part in affairs which properly concern them"
gdfwilliams Posted February 11, 2003 Author Posted February 11, 2003 Mattice - Thanks for the reply. Your solution looks like it would have saved me some time, but as I had already installed Ian's contributions, here's what I've done: [CAVEAT: this is a work in progress. It's working for me in a development environment, but it is currently being built, debugged, etc. I will release a Free Shipping Coupons contribution once I am confident that everything is functioning properly.] First, add a field to cc_coupons called free_ship, integer, default=0, not null in includes/classes/ot_coupon.php: Around line 142 replace: $coupon_get = tep_db_query("select amount, min_order, products, categories, type from cc_coupons where code = '". $coupon_result['coupon_code'] . "'"); $get_result = tep_db_fetch_array($coupon_get); with $coupon_get = tep_db_query("select amount, free_ship, min_order, products, categories, type from cc_coupons where code = '". $coupon_result['coupon_code'] . "'"); $get_result = tep_db_fetch_array($coupon_get); Around line 192, replace: } if ($od_amount>$amount) $od_amount = $amount; return $od_amount; } with } if (($get_result['free_ship']!=0) && ($get_result['min_order'] <= $this->get_order_total())) { $od_amount = $order->info['shipping_cost']; } if ($od_amount>$amount) $od_amount = $amount; return $od_amount; } Around line 204, replace: if ($get_result['products'] || $get_result['categories']) { with: if ($get_result['products'] || $get_result['categories'] || ($get_result['free_ship']!=0)) { That sets the value of the coupon to the shipping price, if the variable free_ship has been flagged in the DB. It also skips the total/tax routine that would otherwise subtract taxes on your voucher amount from your order total. When you create the coupon, the coupon amount doesn't have to be set to anything special (as this will be defined by shipping_total). Coupons will only apply to orders > minimum coupon amount (if set). I'll be working on setting the Free Ship flag in coupon admin and working out the redeem notification. Any additional comments/suggestions, please feel free to share. More to follow. Greg
Recommended Posts
Archived
This topic is now archived and is closed to further replies.