Originally Posted by
tronage
Please forgive me, I'm going to take a stab at reversing the logic for my needs... I would like to hide cod for all the shipping options, and ONLY show it when a local pickup is chosen.
Would this be what I would do (I'm using 1.5.4 if that matters):
/includes/modules/payment/cod.php
Code:
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
if (preg_match('#(storepickup)#i', $_SESSION['shipping']['id'])) {
$this->enabled = true;
}
I "Think" I'm reversing the logic since I'm putting the code into the cod module, and hopefully only enabling it if the storepickup is chosen... And I copied the $this statement from my current cod.php file (which looked a little different then the quoted one, I'm guessing changes for 1.5.4?). In any case before I go hacking away and screwing something up, the question is if the above "should" work?
You probably want:
Code:
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
if ($this->enabled) {
$this->enabled = (bool)preg_match('#(storepickup)#i', $_SESSION['shipping']['id']);
}
That teeny change does two things:
- It only enables the module if it's enabled in your admin
- If enabled in the admin, it's only enabled if the shipping method chosen is "Store Pickup". The value returned by preg_match is either 0 (no match), 1 (match) or false (error), so casting its return to a boolean value results in COD being enabled only if there is a match.
Bookmarks