Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / COD module, display of text description

COD module, display of text description

Views: 893

Results 1 to 7 of 7
15 Jun 2016, 11:06 AM
#1
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,866
Plugin Contributions:
7

COD module, display of text description

var $code, $title, $description, $enabled;

// class constructor
function cod() {
global $order;

  $this->code = 'cod';
  $this->title = MODULE_PAYMENT_COD_TEXT_TITLE;
  **$this->description = MODULE_PAYMENT_COD_TEXT_DESCRIPTION**;

As far as I can see, the constant MODULE_PAYMENT_COD_TEXT_DESCRIPTION, albeit defined and stuffed into $description, does not actually get used/shown/output anywhere.

Am I correct?

15 Jun 2016, 11:18 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: COD module, display of text description

Use of $description is not limited to COD, but included in all payment modules based on a sample of payment modules from the includes/modules/payment directory...

15 Jun 2016, 11:29 AM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,866
Plugin Contributions:
7

Re: COD module, display of text description

Use of $description is not limited to COD, but included in all payment modules based on a sample of payment modules from the includes/modules/payment directory...

Yes, $description is "defined"...but is it actually "used"?

15 Jun 2016, 11:37 AM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: COD module, display of text description

torvista:

Yes, $description is "defined"...but is it actually "used"?

Search of php files for ->description found the only use as an assignment of the constant to it. Nothing that used it. Going to try to expand the search to other potential uses. Note, it is also used in payment modules. Previous post was to identify that applies to more than just COD and appears to be either for a future feature or leftover from a past one (haven't gone searching older versions for the same.)

15 Jun 2016, 11:41 AM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: COD module, display of text description

Nope, didn't find it used anywhere else when using developers toolkit to search 'everything' for ->description on the catalog side. Guess could check the admin side as well...

15 Jun 2016, 11:44 AM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: COD module, display of text description

Ah ha. It's used in admin/modules.php so it appears...

15 Jun 2016, 5:35 PM
#7
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,866
Plugin Contributions:
7

Re: COD module, display of text description

I have been digging in this, cleaning up ancient hacks to show additional information with each of the payment modules on offer in the catalog.

I think the process is worthy of documentation, and maybe some reworking...

MODULE_PAYMENT_COD_TEXT_TITLE - used in catalog and admin
MODULE_PAYMENT_COD_TEXT_DESCRIPTION - used in admin only, in the infobox.

Note that changes in override files are not used/do not show up in the admin, only the original constants.

To use MODULE_PAYMENT_COD_TEXT_DESCRIPTION in the catalog a couple of edits are required
in the payment module

function selection() {//steve edited - shown on checkout_payment
/* ORIGINAL return array('id' => $this->code,
'module' => $this->title);*/

    return array('id' => $this->code,
        'module' => $this->title,
        **'description' => $this->description);//steve added**
}

Now in tpl_checkout_payment.php it can be used

<label for="pmt-<?php echo $selection[$i]['id']; ?>" class="radioButtonLabel"><?php echo $selection[$i]['module']; ?></label>
<?php echo $selection[$i]['description']; //steve added ?>

I wanted to add icons in that description which would have shown up in the admin as broken links, but since the overrides are not used in the admin, it's ok.

Or, you can add an extra define eg:
MODULE_PAYMENT_COD_ICON

add the code:

function selection() {//steve edited - shown on checkout_payment
/* ORIGINAL return array('id' => $this->code,
'module' => $this->title);*/

    return array('id' => $this->code,
        'module' => $this->title,
        'description' => $this->description,
        **'icon' => MODULE_PAYMENT_COD_ICON);//steve added**
}

and in the template

> <label for="pmt-<?php echo $selection[$i]['id']; ?>" class="radioButtonLabel"><?php echo $selection[$i]['module']; ?></label>
**<?php echo $selection[$i]['icon']; //steve added ?>**
<?php echo $selection[$i]['description']; //steve added ?>

There is another built-in way which in the end I have opted to use.

In the module:

function selection() {//steve edited - shown on checkout_payment
/* ORIGINAL return array('id' => $this->code,
'module' => $this->title);*/

    return array('id' => $this->code,
             'module' => $this->title,
             **'fields'=>array(array('title' =>MODULE_PAYMENT_COD_CATALOG_ICON,
                                              'field' => MODULE_PAYMENT_COD_TEXT_DESCRIPTION)) **);
    
}

and this gets output automatically by the original code in the tpl_checkout_payment.php:

<div class="ccinfo"> <?php for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) { ?> <label <?php echo (isset($selection[$i]['fields'][$j]['tag']) ? 'for="'.$selection[$i]['fields'][$j]['tag'] . '" ' : ''); ?>class="inputLabelPayment"><?php echo $selection[$i]['fields'][$j]['title']; ?></label><?php echo $selection[$i]['fields'][$j]['field']; ?> <br class="clearBoth" /> <?php } ?> </div>

I note the "title" array item is wrapped in a label tag and provision is made to add the "for" tag to this label. Not sure what the reasoning behind this is/was. Possibly to make the whole text block clickable to select the radio button?
In which case the template needs to be modified.

<label <?php echo (isset($selection[$i]['fields'][$j]['tag']) ? 'for="**pmt-**'.$selection[$i]['fields'][$j]['tag'] . '" ' : ''); ?>class="inputLabelPayment"><?php echo $selection[$i]['fields'][$j]['title']; ?></label><?php echo $selection[$i]['fields'][$j]['field']; ?>

So, several ways to skin the cat here. I prefer the last method to add extra info to the payment method. It needs some styling to get it shipshape but I just wanted to explain the bones of it.

I also put the payment methods in divs with styling to better control the positioning of the subsequent text.

And on the checkout confirmation page, you can do similar stuff with this function in the module:

> function confirmation() {//steve edited, shown on checkout_confirmation
  return array('title' => '',
               'fields'=>array(array('title' =>MODULE_PAYMENT_COD_CATALOG_ICON',
                'field' => MODULE_PAYMENT_COD_TEXT_DESCRIPTION)) );
}