You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
Pages: 1
There is some critter on this forum called (probably Nick ) who has a habit of modifying this post. - Well there is no need, - my comments about the lack of technical support were (and still are) perfectly justified. - There are three people trying to give help on this forum who actually have any serious know-how of the CCP software. - The rest of us vary from helpful novices to codemasters of variable skill in different fields, some with a good know-how of CCP and some not, and depending on just three people is not working. - They do their best and seriously help people, but a much better system could definitely be implemented (especially when even small modifications that most customers could be guided through without too much difficulty in a matter of 10 minutes are set to cost such customers upto £600 (over $1000) if they need to pay someone to do the work for them.
Anyway... following some form code amendments by Howard, and being totally ignored in my requests for additional help in amending said code in order to allow me to move the buttons up into the header space (just above the product listing), I came up with a fix of my own:
clone the namespace:
// gbu0.prodshowopt
Name the new namespace and amend the new namespace details accordingly
clone the form:
// gbu0.prodaddtocart
Name the new form and amend the new form details accordingly
clone :
// gbu0.prodaddtocart.quantity
Name the new formfield and amend the new formfield details accordingly
Add the following function to :
// +------------------------------------------------------------------+ // | Function: prodshowopt_buttons | // +------------------------------------------------------------------+ function prodshowopt_buttons ($input = array()) { // +-- // | This function prints the product options form. This form contains // | the quantity field by default and may add options to that form. // +-- $product = $this->globals('ecom.prod_proddetail'); if (empty($product)) {return 1;} // +-- // | Load a KHXC_Form object if it hasn't been loaded already. // +-- if (empty($this->KHXC_Form)) { $this->KHXC_Form =& $this->quick_object('KHXC_Form','khxc'); if ($this->IsError($this->KHXC_Form)) {return $this->KHXC_Form;} } // End of if statement. // +-- // | Set our form id. // +-- $formid = $this->app . '--prodaddtocart_buttons--' . $product['id']; // +-- // | Define the form. // +-- $def_form = $this->KHXC_Form->def_form(array('app' => $this->app, 'form' => $this->app . '.prodaddtocart_buttons')); if (($this->IsError($def_form)) || (empty($def_form))) { if ($this->debug) {$this->debugger("prodshowopt_buttons: Error defining product option form.");} return 1; } // End of if statement. $def_form['form'] = $formid; // +-- // | Pop the quantity field. // +-- $quan_field = $def_form['fields'][0]; $quan_field['id'] = $formid . '.quantity'; unset($def_form['fields'][0]); // +-- // | Modify the name of the button for this form. // +-- $addtocart_text = $this->globals('khxc_settings.' . $this->app . '.lang.ADDTOCART'); $this->globals('khxc_form.submit_modify',$addtocart_text); // +-- // | Add our prodall, referring ref and referring namespace fields. // +-- $def_form['fields'][] = array('id' => $formid . '--prodall', 'section' => 'HIDDEN', 'name' => 'prodall', 'description' => '', 'required' => 1, 'type' => 'HIDDEN-REG', 'typeparam' => '', 'defaultvalue' => $product['id'], 'values' => array(), 'maxlength' => 0); $def_form['fields'][] = array('id' => $formid . '--referref', 'section' => 'HIDDEN', 'name' => 'referref', 'description' => '', 'required' => 1, 'type' => 'HIDDEN-REG', 'typeparam' => '', 'defaultvalue' => $this->globals('khxc.ref'), 'values' => array(), 'maxlength' => 0); $def_form['fields'][] = array('id' => $formid . '--referns', 'section' => 'HIDDEN', 'name' => 'referns', 'description' => '', 'required' => 1, 'type' => 'HIDDEN-REG', 'typeparam' => '', 'defaultvalue' => $this->globals('khxc.namespace'), 'values' => array(), 'maxlength' => 0); // +-- // | Push the quantity field back onto the form. // +-- $def_form['fields'][] = $quan_field; // +-- // | Work with KHXC_Form to print the form. // +-- $spec_form = $this->KHXC_Form->spec_form($def_form); $result = $this->KHXC_Form->print_form($spec_form); if ($this->debug) {$this->debugger("prodshowopt_buttons: Printed the product options form.");} // +-- // | Return true. // +-- return 1; } // End of function.
Clone
...and add the code that follows the following code snippet to the cloned file somewhere near the bottom where you have:
<?php print $proddesc; ?>
<?php // +-- // | Print the product options if we can add the item to the // | shopping cart or wish list and we're on the prodshow // | namespace. // +-- $add_ok = 1; if (($proddisp['useinv']) && (!($proddisp['invlevel'] > 0))) {$add_ok = 0;} if ($proddisp['pricestatus'] == 'D') {$add_ok = 0;} if (($ns == 'prodshow') && ($add_ok)) { $this->include_namespace($app,'prodshowopt_buttons',array()); } // End of if statement. ?> <?php $formid = $this->xhtml_encode($this->globals('khxc_form.formid')); $url = $this->xhtml_encode($this->globals('khxc_form.url')); $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_buttons/',$formid)) {$isaddtocart = 1;} $show_wl = 0; if (preg_match('/\-\-prodaddtocart_buttons/',$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 (preg_match('/\-\-prodaddtocart_buttons/',$formid)) { print '<form action="' . $url . '" method="' . $method . '" id="' . $formid . '" />' . $eol . $eol; } // End of if statement. if ($ns == 'prodshow') { print '<p><input class="khxc_formbutton_purchase" type="submit" name="SUBMIT" id="'; print $formid . '--SUBMIT" value="' . $buttname; print '" onclick="return DisableSubmit(\'' . $formid . '\');" '; print 'onkeypress="return DisableSubmit(\'' . $formid . '\');" />'; if ($show_wl) { print ' <input class="khxc_formbutton" type="submit" name="WISHLIST" id="'; print $formid . '--WISHLIST" value="Would Like To Purchase" /></p>'; } // End of if statement. } // End of if statement. ?>
Replace (integrate carefully if you already have a modified !)...
<?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'); $ns = $this->globals('khxc.namespace'); 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. $eol = $this->globals('khxc.eol'); if ($description) { if ($desc_has_tags) { print $description . $eol . $eol; } else { print '<p>' . $description . '</p>' . $eol . $eol; } // End of if statement. } // End of if statement. if (($required) && ($show_wl)) { print '' . $eol . $eol; } elseif ($required) { print '' . $eol . $eol; } else { print '<p>Click the \'' . $buttname . '\' button at the bottom of this form to proceed.</p>' . $eol . $eol; } // End of if statement. if ($upload) { print '<form action="' . $url . '" method="' . $method . '" id="' . $formid . '" enctype="multipart/form-data" >' . $eol . $eol; } elseif (!(preg_match('/\-\-prodaddtocart_buttons/',$formid))) { print '<form action="' . $url . '" method="' . $method . '" id="' . $formid . '">' . $eol . $eol; } // End of if statement. ?>
Replace (integrate carefully if you already have a modified !)...
<?php $app = $this->globals('khxc_display.app'); $eol = $this->globals('khxc.eol'); $formid = $this->xhtml_encode($this->globals('khxc_form.formid')); $buttname = $this->globals('khxc_form.submit_modify'); $disablewl = $this->globals('khxc_settings.' . $app . '.disablewishlist'); $ns = $this->globals('khxc.namespace'); if (empty($buttname)) {$buttname = 'Submit';} else {$buttname = $this->xhtml_encode($buttname);} $isaddtocart = 0; if (preg_match('/\-\-prodaddtocart/',$formid)) { $isaddtocart = 1; } print '<p>'; if ($ns != 'prodshow') { if (empty($isaddtocart)) { 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 . '\');" />'; print ' <input class="khxc_formbutton" type="submit" name="ns" id="'; print $formid . '--CANCEL" value="Cancel" />'; } 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="Add To Wish List" />'; } // End of if statement. } // End of if statement. } // End of if statement. print '</p>' . $eol . $eol; if (!(preg_match('/\-\-prodaddtocart_buttons/',$formid))) { print '</form>' . $eol . $eol; } ?>
You now have a default format cloned product detail page that, when used with any of your product listings, will give you the and buttons at the of your listings and buttons below the listings.
I am not sure about the CCP naming conventions, so change the GBU references to whatever is correct for CCP if necessary.
I do not use or , so you may need to change a couple of small details there, too.
The Default Format used in the example given below is based on my float display default format and is designed to float the content of your listings around the image so if you see that happening it probably is as a result of something going horribly wrong with the code!
Implemented correctly this should also validate.
A sample page (with notes as shown above):
<?php $app = $this->globals('khxc.app'); $ns = $this->globals('khxc.namespace'); $eol = $this->globals('khxc.eol'); $proddisp = $this->globals('ecom.prod_proddetail'); $prodimg = $proddisp['imgsm']; $prodnum = $proddisp['prodnum']; $brand = $proddisp['brand']; $tagline = $proddisp['ptag']; $xid = $proddisp['id']; $id = $this->xhtml_encode($xid); $usethumb = $this->globals('khxc_settings.' . $app . '.imguseprodthumb'); $imgwidthth = $this->globals('khxc_settings.' . $app . '.imgsizeprodlgth'); if ($ns == 'addcart') {$ns = 'prodshow';} $this->globals('ecom.prod_proddisp',$proddisp); $this->globals('ecom.prod_priceinfo',$proddisp['khxc.priceinfo']); // +-- // | Create the product name and description. // +-- $prodname = $this->xhtml_encode($proddisp['name']); $proddesc = $proddisp['desclong']; $desc_has_tags = $this->has_tags($proddesc); if (empty($proddesc)) { $proddesc = $proddisp['descshort']; $desc_has_tags = 0; } // End of if statement. if (empty($desc_has_tags)) {$proddesc = '<p>' . $this->xhtml_encode($proddesc) . '</p>';} // +-- // | Create the image tag(s). // +-- $imglistlg = $proddisp['imglg']; if (empty($imglistlg)) {$imglist = 'none.png';} $imglistlg = $this->make_list($imglistlg); $imgwidth = $this->globals('khxc_settings.' . $app . '.imgsizeprodlg'); $imgtag = ''; if (empty($imgwidth)) {$imgwidth = 200;} $count = 0; $multilg = 0; foreach ($imglistlg as $num => $name) { if ($count == 0) { $lgimname = $name; } $count++; } // End of foreach statement. if ($count > 1) { // We have multi large images. $multilg = 1; } // End of if statement. if (($multilg) && ($usethumb)) { $imgtag .= '<script type="text/javascript">' . $eol; $imgtag .= '<!--' . $eol; $imgtag .= 'if(document.images) { // create an array of prodImages' . $eol; $imgtag .= 'document.prodImages = new Array();' . $eol; } foreach ($imglistlg as $num => $img) { if (($multilg) && ($usethumb)) { $imgurl = 'media/' . $app . '/prodlg/' . $img; $imgtag .= 'document.prodImages[' . $num . '] = new Image();' . $eol; $imgtag .= 'document.prodImages[' . $num . '].src = "' . $imgurl . '";' . $eol; $imgtag .= 'document.prodImages[' . $num . '].pop = "' . $imgurl . '";' . $eol; } else { $imgurl = 'media/' . $app . '/prodlg/' . $img; $imgtag .= '<img src="' . $imgurl . '" '; // Sets the image width size for the large image display according to backend setting if ($imgwidth) {$imgtag .= 'width="' . $imgwidth . '" ';} $imgtag .= 'alt="' . $prodname . '" />'; } // End of if statement. } // End of foreach statement. if (($multilg) && ($usethumb)) { $imgtag .= '//-->' . $eol; $imgtag .= '}' . $eol; $imgtag .= '</script>' . $eol; $imgurl = 'media/' . $app . '/prodlg/' . $lgimname; $imgtag .= '<img src="' . $imgurl . '" '; if ($imgwidth) {$imgtag .= 'width="' . $imgwidth . '" ';} $imgtag .= 'alt="' . $prodname . '" id="prodImage" />'; } // End of if statement. // +-- // | Handle extra large image. // +-- $showxl = 0; $imglistxlg = $proddisp['imgxl']; if (empty($imglistxlg)) {$imglistxlg = 'none.png';} if (($imglistxlg) && ($imglistxlg != 'none.png') && ($ns == 'prodshow')) { $this->globals('khxc.load_lightbox',1); $showxl = 1; $xlcount = 0; $xlimgtag = ''; $zlcount = count($imglistxlg); $imglistxlg = $this->make_list($imglistxlg); if (count($imglistxlg) == 1) {$text = 'View Larger Image';} else {$text = 'View Larger Image Slideshow';} foreach ($imglistxlg as $num => $img) { $xlcount++; $xlurl = $this->globals('khxc.url_nonssl'); $xlurl .= '/media/' . $app . '/prodxl/' . $img; if ($xlcount == 1) { $xlimgtag .= '<p><a href="' . $xlurl . '" rel="lightbox[prodgroup]" title="'; $xlimgtag .= $prodname . '" class="khxc_hrefbutton">' . $text . '</a></p>'; } else { $xlimgtag .= '<p class="hidden"><a href="' . $xlurl . '" rel="lightbox[prodgroup]" title="'; $xlimgtag .= $prodname . '" class="khxc_hrefbutton">' . $text . '</a></p>'; } // End of if statement. } // End of foreach statement. } // End of if statement. if (($multilg) && ($usethumb)) { $imgtag .= '<p>'; foreach ($imglistlg as $num => $name) { $imgurl = 'media/' . $app . '/prodlg/' . $name; $imgtag .= '<img src=\'' . $imgurl . '\' onmouseover="var x=document.getElementById(\'prodImage\'); x.src=document.prodImages[' . $num . '].src;" width="' . $imgwidthth . '" alt="' . $prodname . '" />'; } // End of foreach statement. $imgtag .= '</p>'; } // End of if statement. // +-- // | Print the display. // +-- ?> <table id="proddetail--<?php print $id; ?>" class="khxc_cptbl_det"> <tr class="khxc_cptbl_det"> <td class="khxc_cptbl_det"> <?php if ($prodnum == 'LDW_Self_Adhesive_Bumper_Feet'){ print '<div style="float: left; width: 100px; padding: 0 10px 0 0;">'; } else { print '<div style="float: left; width:' . $imgwidth . 'px; padding: 0 10px 10px 0;">'; } ?> <?php if (($showxl) && ($prodnum != 'LDW_Self_Adhesive_Bumper_Feet')) { print $xlimgtag; } if ($prodnum == 'LDW_Self_Adhesive_Bumper_Feet') { print '<img src="media/' . $app . '/prodsm/' . $prodimg . '" alt="" />'; } else { print $imgtag; } ?> <?php // +-- // | Handle the extra large image tag and email a friend link. // +-- $emailfr = $this->globals('khxc_settings.' . $app . '.emailfriend'); if ($ns != 'prodshow') {$emailfr = 0;} if ($prodnum == 'LDW_Self_Adhesive_Bumper_Feet') { print '<div style="width: 100px;">' . $eol; if ($emailfr) { $link_emailf = $this->link_namespace($app,'emailfriend',array('ref' => $proddisp['id'])); print '<p><a href="' . $link_emailf . '" title="Tell Someone About This Item!" '; print 'class="khxc_hrefbutton_friend">Tell Someone About This Item!</a></p>'; } // End of if statement. print '</div>' . $eol; } elseif (($showxl) || ($emailfr)) { print '<div style="width:' . $imgwidth . 'px">' . $eol; if ($emailfr) { $link_emailf = $this->link_namespace($app,'emailfriend',array('ref' => $proddisp['id'])); print '<p><a href="' . $link_emailf . '" title="Tell Someone About This Item!" '; print 'class="khxc_hrefbutton_friend">Tell Someone About This Item!</a></p>'; } // End of if statement. print '</div>' . $eol; } // End of if statement. ?> </div> <?php // +-- // | Print the product options if we can add the item to the // | shopping cart or wish list and we're on the prodshow // | namespace. // +-- $add_ok = 1; if (($proddisp['useinv']) && (!($proddisp['invlevel'] > 0))) {$add_ok = 0;} if ($proddisp['pricestatus'] == 'D') {$add_ok = 0;} if (($ns == 'prodshow') && ($add_ok)) { $this->include_namespace($app,'prodshowopt_buttons',array()); } // End of if statement. ?> <?php $formid = $this->xhtml_encode($this->globals('khxc_form.formid')); $url = $this->xhtml_encode($this->globals('khxc_form.url')); $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_buttons/',$formid)) {$isaddtocart = 1;} $show_wl = 0; if (preg_match('/\-\-prodaddtocart_buttons/',$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 (preg_match('/\-\-prodaddtocart_buttons/',$formid)) { print '<form action="' . $url . '" method="' . $method . '" id="' . $formid . '" />' . $eol . $eol; } // End of if statement. if ($ns == 'prodshow') { print '<p><input class="khxc_formbutton_purchase" type="submit" name="SUBMIT" id="'; print $formid . '--SUBMIT" value="' . $buttname; print '" onclick="return DisableSubmit(\'' . $formid . '\');" '; print 'onkeypress="return DisableSubmit(\'' . $formid . '\');" />'; if ($show_wl) { print ' <input class="khxc_formbutton" type="submit" name="WISHLIST" id="'; print $formid . '--WISHLIST" value="Would Like To Purchase" /></p>'; } // End of if statement. } // End of if statement. ?> <p style="font-weight: bold; color: black; text-align: justify;"> <?php print $prodname; ?> </p> <?php if (!empty($brand)) { print '<p style="padding: 15px 0 0 0; color: black;"><strong>Make - Model:</strong> ' . $brand . '</p>'; } ?> <?php $this->include_file($app,'pricedisp.php'); ?> <?php print $proddesc; if ($tagline == 'Litez_Lamps') { print '<p style="padding: 20px 0 0 0;">'; include '/var/lamps.php'; print '</p>'; } ?> </td> </tr> </table> <?php // +-- // | Print the product options if we can add the item to the // | shopping cart or wish list and we're on the prodshow // | namespace. // +-- $add_ok = 1; if (($proddisp['useinv']) && (!($proddisp['invlevel'] > 0))) {$add_ok = 0;} if ($proddisp['pricestatus'] == 'D') {$add_ok = 0;} if (($ns == 'prodshow') && ($add_ok)) { $this->include_namespace($app,'prodshowopt',array()); } // End of if statement. ?>
The quantity boxes can be hidden if need be, but don't forget to set them as not required first or you will end up with products that cannot be added to the basket because something has not been completed (which, of course, your customers will not be able to complete because the box will be hidden!).
Also there are some bits in the sample page that you may not want ...which I will help with if I can.
Last edited by Design_Wholesale (01-10-2011 20:22:41)
Offline
Pages: 1