Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
 All Forums
 Technical
 Advanced Tips and Tricks - NO QUESTIONS PLEASE
 Ask a Question for zero price and other places
Author « Topic »  

dbdave
ECT Moderator

USA
10271 Posts

Posted - 08/04/2018 :  15:09:24  
It's possible to trigger the ask a question feature from locations other than the default button. In fact, you can hide that button and use your own button, or even just a text link.
This can be done with no edits to the core files (update proof) and I have working examples.
Here on the forum, it was recently asked if it's possible to re purpose the pricezeromessage parameter to trigger the ask-a-question feature.
Below is what I demonstrate, but with some changes, it's possible to use this in your product description or a custom field perhaps, allowing you to place the ask a question feature just about anyplace without interfering with the native button or your social media buttons.

Note, this code is free to use and being that I am just an ect cart lovin' user like you, this is not supported by ect.

First, you must have the ask-a-question feature enabled for your site (moreinfo below), and of course, you want to make sure your store is properly sending emails.

:: Make sure Ask a Question is setup ::
Most users will be using css layouts ((.asp) usecsslayout=TRUE or (.php) $usecsslayout=TRUE;), so you setup the ask-a-question feature by setting the elements on your product detail and product pages with the following
product details - https://www.ecommercetemplates.com/help/css-layouts.asp#proddetailorder
products page - https://www.ecommercetemplates.com/help/css-layouts.asp#productorder
You will add the social media there and then decide on what buttons to show (info here --> https://www.ecommercetemplates.com/help/social-media.asp#define )

:: How it works ::
What we will do is use the same method the cart uses to get the ask-a-question feature to activate. The trick is that the ask-a-question feature needs to know the product ID of the item the user will be asking about.
We will populate that and set this up so you can insert a simple html tag to get it to show wherever you want.
NOTE - We are using an html ID to target the location where you want this to show, it is designed to show only once and will not work correctly if you try to add it to more than one location for a given product.
:: .ASP version ::
:: EXAMPLE 1 for use with zero price message::
Open proddetail.asp in your html editor. In the content area you will find the include line
<!--#include file="vsadmin/inc/incproddetail.asp"-->
Just above that line add the following line
<%pricezeromessage="<span id=""askaq""></span>"%>

and just below that add the following code
<script>
var ques = ('Email for Price'); // <--- you can change Email for Price to anything you like
if (document.getElementById('askaq') != null) {
var askque = ('<input value="'+ques+'" class="askaquestion" onclick="openEFWindow(\'<%= productid %>\',true)" type="button">');
document.getElementById('askaq').innerHTML = askque; }
</script>

The code above gives a button that uses the same class as the native ask-a-question button. You can change the name of the class there to something different. Alternately, if you just want plain text, and not an input button, you can
replace this line
var askque = ('<input value="'+ques+'" class="askaquestion" onclick="openEFWindow(\'<%= productid %>\',true)" type="button">');
with
var askque = ('<a class="queslink" style="cursor:pointer;" onclick="openEFWindow(\'<%= productid %>\',true)">'+ques+'</a>');

Just upload the file to the server and that should be it. Any product with a zero price will show the ask a question button
demo here - http://www.floridasurpluswarehouse.com/dev/proddetail.php?prod=serialcab001

For the products page, it is possible to set this up, but the code would have to be custom based on the elements your are using on the page.
I recommend that you set <%pricezeromessage="View Product Details"%> just above <!--#include file="vsadmin/inc/incproducts.asp"--> on the products.asp page for the price zero message use.
example - http://www.floridasurpluswarehouse.com/dev/products.php?cat=3
:: EXAMPLE 2 usage in the product description with the text link instead of the button::
Open proddetail.asp in your html editor. In the content area you will find the include line
<!--#include file="vsadmin/inc/incproddetail.asp"-->
just below that add the following code
<script>
var ques = ('Ask a Question'); // <--- you can change Ask a Question to anything you like
if (document.getElementById('askaq') != null) {
var askque = ('<a class="queslink" style="cursor:pointer;" onclick="openEFWindow(\'<%= productid %>\',true)">'+ques+'</a>');
document.getElementById('askaq').innerHTML = askque; }
</script>

Upload the file to the server.

Now in your product description (or one of the custom fields) you can add this simple line - <span id="askaq"></span> to get it to show
demo here - http://www.floridasurpluswarehouse.com/dev/proddetail.php?prod=testproduct

:: .PHP version ::
:: EXAMPLE 1 for use with zero price message::

Open proddetail.php in your html editor. In the content area you will find the include line
<?php include "vsadmin/inc/incproddetail.php" ?>
Just above that line add the following line
<?php $GLOBALS['pricezeromessage']="<span id='askaq'></span>";?>

and just below that add the following code
<script>
var ques = ('Email for Price'); // <--- change Email for Price to anything you like
if (document.getElementById('askaq') != null) {
var askque = ('<input value="'+ques+'" class="askaquestion" onclick="openEFWindow(\'<?php print $productid;?>\',true)" type="button">');
document.getElementById('askaq').innerHTML = askque; }
</script>

The code above gives a button that uses the same class as the native ask-a-question button. You can change the name of the class there to something different. Alternately, if you just want plain text, and not an input button, you can

replace this line
var askque = ('<input value="'+ques+'" class="askaquestion" onclick="openEFWindow(\'<?php print $productid;?>\',true)" type="button">');
with
var askque = ('<a class="queslink" style="cursor:pointer;" onclick="openEFWindow(\'<?php print $productid;?>\',true)">'+ques+'</a>');

Just upload the file to the server and that should be it. Any product with a zero price will show the ask a question button
demo here - http://www.floridasurpluswarehouse.com/dev/proddetail.php?prod=serialcab001

For the products page, it is possible to set this up, but the code would have to be custom based on the elements your are using on the page.
I recommend that you set <?php $GLOBALS['pricezeromessage']="View Product Details";?> just above <?php include "vsadmin/inc/incproducts.php" ?> on the products.php page for the price zero message use.
example - http://www.floridasurpluswarehouse.com/dev/products.php?cat=3
:: EXAMPLE 2 usage in the product description with the text link instead of the button::
Open proddetail.php in your html editor. In the content area you will find the include line
<?php include "vsadmin/inc/incproddetail.php" ?>
just below that add the following code
<script>
var ques = ('Ask a Question'); // <--- change Ask a Question to anything you like
if (document.getElementById('askaq') != null) {
var askque = ('<a class="queslink" style="cursor:pointer;" onclick="openEFWindow(\'<?php print $productid;?>\',true)">'+ques+'</a>');
document.getElementById('askaq').innerHTML = askque; }
</script>

Upload the file to the server.

Now in your product description (or one of the custom fields) you can add this simple line - <span id="askaq"></span> to get it to show
demo here - http://www.floridasurpluswarehouse.com/dev/proddetail.php?prod=testproduct

Edited by - dbdave on 08/04/2018 15:13:21
  « Topic »  
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.03 seconds. Snitz Forums 2000