After several hours work I have managed to come up with the following, which works perfectly provided I want a working Add to Wish List button or a working Add to Basket button ...but not both
Currently the following code block gives me a working Add to Basket button...
- Code: Select all
<?php
$app = $this->globals('khxc_display.app');
$form = $this->xhtml_encode($this->globals('khxc_form.form'));
$formid = $this->xhtml_encode($this->globals('khxc_form.formid'));
$url = $this->xhtml_encode($this->globals('khxc_form.url'));
$upload = $this->globals('khxc_form.upload');
$required = $this->globals('khxc_form.required');
$desc_has_tags = $this->has_tags($this->globals('khxc_form.description'));
$buttname = $this->globals('khxc_form.submit_modify');
$disablewl = $this->globals('khxc_settings.' . $app . '.disablewishlist');
if (empty($buttname)) {$buttname = 'Submit';}
else {$buttname = $this->xhtml_encode($buttname);}
$isaddtocart = 0;
if (preg_match('/\-\-prodaddtocart/',$formid)) {$isaddtocart = 1;}
print '<p>';
if (empty($buttname)) {$buttname = 'Submit';}
else {$buttname = $this->xhtml_encode($buttname);}
$show_wl = 0;
if (preg_match('/\-\-prodaddtocart/',$formid)) {$show_wl = 1;}
if (!(empty($disablewl))) {$show_wl = 0;}
$method = 'post';
if (preg_match('/\-\-prodsearch/',$formid)) {$method = 'get';}
if (preg_match('/\-\-minisearch/',$formid)) {$method = 'get';}
if ($desc_has_tags) {
$description = $this->globals('khxc_form.description');
} else {
$description = $this->xhtml_encode($this->globals('khxc_form.description'));
} // End of if statement.
if (empty($isaddtocart)) {
print '<br /><p style="padding: 0 0 0 10px;" /></form><input class="khxc_formbutton" type="submit" name="SUBMIT" id="';
print $formid . '--SUBMIT" value="' . $buttname;
print '" onclick="return DisableSubmit(\'' . $formid . '\');" ';
print 'onkeypress="return DisableSubmit(\'' . $formid . '\');" />';
print ' <input class="khxc_formbutton" type="submit" name="ns" id="';
print $formid . '--CANCEL" value="Cancel" /></p><br />';
} else {
print '<input class="khxc_formbutton" type="submit" name="SUBMIT" id="';
print $formid . '--SUBMIT" value="' . $buttname;
print '" onclick="return DisableSubmit(\'' . $formid . '\');" ';
print 'onkeypress="return DisableSubmit(\'' . $formid . '\');" />';
if (empty($disablewl)) {
print ' <input class="khxc_formbutton" type="submit" name="WISHLIST" id="';
print $formid . '--WISHLIST" value="Would Like To Purchase" />';
} // End of if statement.
} // End of if statement.
if ($upload) {
print '<form action="' . $url . '" method="' . $method . '" id="' . $formid . '" enctype="multipart/form-data" >' . $eol . $eol;
} else {
print '<form action="' . $url . '" method="' . $method . '" id="' . $formid . '">' . $eol . $eol;
} // End of if statement.
?>
...whilst
- Code: Select all
<?php
$app = $this->globals('khxc_display.app');
$form = $this->xhtml_encode($this->globals('khxc_form.form'));
$formid = $this->xhtml_encode($this->globals('khxc_form.formid'));
$url = $this->xhtml_encode($this->globals('khxc_form.url'));
$upload = $this->globals('khxc_form.upload');
$required = $this->globals('khxc_form.required');
$desc_has_tags = $this->has_tags($this->globals('khxc_form.description'));
$buttname = $this->globals('khxc_form.submit_modify');
$disablewl = $this->globals('khxc_settings.' . $app . '.disablewishlist');
if (empty($buttname)) {$buttname = 'Submit';}
else {$buttname = $this->xhtml_encode($buttname);}
$isaddtocart = 0;
if (preg_match('/\-\-prodaddtocart/',$formid)) {$isaddtocart = 1;}
print '<p>';
if (empty($buttname)) {$buttname = 'Submit';}
else {$buttname = $this->xhtml_encode($buttname);}
$show_wl = 0;
if (preg_match('/\-\-prodaddtocart/',$formid)) {$show_wl = 1;}
if (!(empty($disablewl))) {$show_wl = 0;}
$method = 'post';
if (preg_match('/\-\-prodsearch/',$formid)) {$method = 'get';}
if (preg_match('/\-\-minisearch/',$formid)) {$method = 'get';}
if ($desc_has_tags) {
$description = $this->globals('khxc_form.description');
} else {
$description = $this->xhtml_encode($this->globals('khxc_form.description'));
} // End of if statement.
if ($upload) {
print '<form action="' . $url . '" method="' . $method . '" id="' . $formid . '" enctype="multipart/form-data" >' . $eol . $eol;
} else {
print '<form action="' . $url . '" method="' . $method . '" id="' . $formid . '">' . $eol . $eol;
} // End of if statement.
if (empty($isaddtocart)) {
print '<br /><p style="padding: 0 0 0 10px;" /></form><input class="khxc_formbutton" type="submit" name="SUBMIT" id="';
print $formid . '--SUBMIT" value="' . $buttname;
print '" onclick="return DisableSubmit(\'' . $formid . '\');" ';
print 'onkeypress="return DisableSubmit(\'' . $formid . '\');" />';
print ' <input class="khxc_formbutton" type="submit" name="ns" id="';
print $formid . '--CANCEL" value="Cancel" /></p><br />';
} else {
print '<input class="khxc_formbutton" type="submit" name="SUBMIT" id="';
print $formid . '--SUBMIT" value="' . $buttname;
print '" onclick="return DisableSubmit(\'' . $formid . '\');" ';
print 'onkeypress="return DisableSubmit(\'' . $formid . '\');" />';
if (empty($disablewl)) {
print ' <input class="khxc_formbutton" type="submit" name="WISHLIST" id="';
print $formid . '--WISHLIST" value="Would Like To Purchase" />';
} // End of if statement.
} // End of if statement.
?>
gives me a working Add to Wishlist button
Ideally I would like to strip the code for the buttons to an absolute minimum in terms of dependencies and variables in order to allow it to be usable not just within form_header.php, but also within Catalog Product Display files, so's to allow the buttons to be displayed anywhere within the product listing.
There is also the quantity box to think about, but that is usually quite straightforward to implement and I will detail the process of implementing it later on in this post if I can get the buttons repositioned and working.
Can anyone help with this, please?



