soundzgood2 wrote:
That's pretty generous, coupon discount on top of a special price. If you have to track it, why not remove the special price and bump up the coupon discount?
The retail price is a 'game we have to play' and so is the special price.
Everyone in my industry sells the products for 15% or 20% off suggested retail (depending on the manufacturer limit) so everyone has the same product for the same price all the time. So the special price is everyone's normal price.
If we have a product for $100 and are allowed to discount it 20% the price is $80 on every competitors price all the time ---> if we have it for $100 all the time (removing the special price) we would never sell that product; they'd just go to our competitors.
So.... while we are not allowed to advertise the product for less then the maximum discount, and we want to show the discount off MSRP, what we are "allowed" to do is offer, through other avenues (like email, facebook, ect. marketing), coupons that make us cheaper then our competitors.
soundzgood2 wrote:
The calculate_credit function is bound to be buggy, no question. Just seeing those deprecated splits you know that LC 6.5 isn't yet php 5.3 aware.
Here is to hoping 5.3 doesn't come on too fast or LC will be a dead product unless updated very quickly.
soundzgood2 wrote:
I'd like to know what that $t line does too, but the second line is in the $ii loop, so the $ii is the index of the array, so I think legit. Looks to me like it subtracts the special price from the products price and calculates the coupon discount on that figure, which sounds like its what you want it to do. But it's wrapped up in the restricted to categories / products loops, so is it doing what you want for your circumstances? Probably not.
The second line does nothing either
Code:
$pr_c_specail = $this->get_products_special_price($pr_ids[$ii]);
but when I changed the $t line to use the $j variable then put that $t in so the code is:
Code:
$pr_c_specail = $this->get_products_special_price($t);
$t then equals the product id and $pr_c_specail then has values populated.
soundzgood2 wrote:
Why not separate out the function, plug in some test numbers for variables and take it for a spin?
It'll probably be the first time for quite a while anyone will have.
Simon
On this point I'll just say I am a complete untrained hack. Here is what I ended up with on my first attempt:
Code:
if ($get_result['coupon_minimum_order'] <= $this->get_order_total()) {
if ($get_result['restrict_to_products'] || $get_result['restrict_to_categories']) {
if ($get_result['restrict_to_categories']) {
$cat_ids = split("[,]", $get_result['restrict_to_categories']);
for ($j=0; $j < sizeof($order->products); $j++) {
$my_path = tep_get_product_path(tep_get_prid($order->products[$j]['id']));
$sub_cat_ids = split("[_]", $my_path);
for ($iii = 0; $iii < count($sub_cat_ids); $iii++) {
for ($ii = 0; $ii < count($cat_ids); $ii++) {
if ($sub_cat_ids[$iii] == $cat_ids[$ii]) {
if ($get_result['coupon_type'] == 'P') {
$p_processed = true;
// $i was wrong so changed to $j for the next line below $t = tep_get_prid($order->products[$i]['id']);
$t = tep_get_prid($order->products[$j]['id']);
$pr_c = $this->product_price(tep_get_prid($order->products[$j]['id']));
$pr_c_specail = $this->specialPrice=tep_get_products_special_price($t); // 2nd attempt seems to work (right product price)
// $pr_c -= $pr_c_specail; // orig
$pr_c_specail += $pr_c_specail; // my change to add up discounted product prices
//original discount math $pod_amount = tep_round($pr_c*10,2)/10*$c_deduct/100);
$pod_amount = ((tep_round($pr_c_specail*10,2)/10*$c_deduct/100)/2); // used $pr_c_specail after my addition above but it was double so I also added the /2 to devide it in half!!
$od_amount = $od_amount + $pod_amount;
continue 3;
} else {
$od_amount = $c_deduct;
continue 3;
But as indicated I'm a hack and while it worked for a quantity of 1 of the products in the cart when the product was 2 or more the discount was only taken on one. So I tried to multiply by the $qty in that code section i.e. $pr_c_specail = $pr_c_specail * $qty; but of course at that place in the code $qty equals nothing.
So that said to me I have no clue what I'm doing... lol (but oh so close).
Mike