Forums / Templates, Stylesheets, Page Layout / Putting Sale text in header from Sales manager

Putting Sale text in header from Sales manager

Views: 592

Results 1 to 3 of 3
27 Mar 2016, 7:57 PM
#1
fjolsvith avatar

fjolsvith

New Zenner

Join Date:
Mar 2016
Location:
Norcatur, Kansas, USA
Posts:
88
Plugin Contributions:
2

Putting Sale text in header from Sales manager

Okay, so I have my store running. I am running a sale right now, but I want a snippet of code put into my header.php that will:

  1. Parse the sales list in the database (that are defined in the Sales Manager).
  2. Gets sale information for the sale with the lowest ZOrder.
  3. Defines HEADER_SALES_TEXT with the following "Take advantage of our " + Sales Name + " Sale and save " + Sale Amount Off + " through " + End of Sale Date + "!"

This would allow my sales in my Sales manager to automatically update the header as sales are created and deleted.

Anyone have an idea of how to do this?

27 Mar 2016, 9:30 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Putting Sale text in header from Sales manager

In your template's tpl_header.php there is a section of code similar to this:```

<?php if (HEADER_SALES_TEXT != '') { ?>
  <div id="tagline"><?php echo HEADER_SALES_TEXT;?></div>
<?php } ?>

You could change it to something like this:```
<?php
$saleDetails = $db->Execute("select * from " . TABLE_SALEMAKER_SALES . " where sale_status=1 order by sale_date_end asc, sale_id asc");
if ($saleDetails->RecordCount()) {
  $saleTitle = $saleDetails->fields['sale_name'];
  $saleAmount = number_format($saleDetails->fields['sale_deduction_value'], 2); // might have to adjust depending on sale_deduction_type setting
  $saleExpiry = $saleDetails->fields['sale_date_end']; // might have to adjust if you forget to set an expiry date
?>
      <div id="tagline">Take advantage of our <?php echo $saleTitle;?> Sale and save <?php echo $saleAmount;?> through <?php echo $saleExpiry;?>!</div>
<?php
              }
?>

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

27 Mar 2016, 11:23 PM
#3
fjolsvith avatar

fjolsvith

New Zenner

Join Date:
Mar 2016
Location:
Norcatur, Kansas, USA
Posts:
88
Plugin Contributions:
2

Re: Putting Sale text in header from Sales manager

Okay, I figured out what should be inserted:

<?php
$saleDetails = $db->Execute("select * from " . TABLE_SALEMAKER_SALES . " where sale_status=1 order by sale_date_end asc, sale_id asc");
if ($saleDetails->RecordCount()) {
$saleTitle = $saleDetails->fields['sale_name'];
$saleAmount = number_format($saleDetails->fields['sale_deduction_value'], 2); // might have to adjust depending on sale_deduction_type setting
$saleExpiry = $saleDetails->fields['sale_date_end']; // might have to adjust if you forget to set an expiry date
?>
      <div id="tagline">Take advantage of our <?php echo $saleTitle;?> Sale and save <?php 
if ($saleDetails->fields['sale_deduction_type'] == 2) echo '$';
echo round($saleAmount); 
if ($saleDetails->fields['sale_deduction_type'] == 1) echo '%';
?> through <?php echo $saleExpiry;?>!</div>