Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Aug 2005
    Posts
    154
    Plugin Contributions
    0

    help question Inserting price on non-zen html page on website

    I have a standard html page (I can make it php if necessary) that has some items listed on it in a sidebar. I have hard-coded these items into that page and when I change the price of an item on the admin I have to go and seperately edit the html page to reflect those changes.

    Is there a php command I can use to just grab an item's price? For example something like:
    Code:
    <?php require /index.php?main_page=product_info&cPath=3&products_id=2&action=price ?>
    If I could get Zen to just return the price to me then that code would work and I could put that in my static page so it would then show dynamic pricing based on the cart's price! :-)

  2. #2
    Join Date
    May 2006
    Posts
    80
    Plugin Contributions
    0

    Default Re: Inserting price on non-zen html page on website

    Its not as easy as just adding a bit of php code. There are many variables that make up the price. Im guessing you did not find an answer?

    I have been trying to work this out for a while now.

    Please can anyone point us in the right direction?

    I desperately need to display the price of certain products in the main description on category pages. I could hard code them but the site is multi currency so this will not work.

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Inserting price on non-zen html page on website

    Within the Zen Cart environment you can run most any php code anywhere ...

    Outside the Zen Cart environment you are missing a lot of information that is needed to manipulate the database and processes the products ...

    You can look in the Downloads for an add-on for a sidebox outside of Zen Cart but I you will need to run php pages as HTML pages don't think ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  4. #4
    Join Date
    May 2006
    Posts
    80
    Plugin Contributions
    0

    Default Re: Inserting price on non-zen html page on website

    I am trying to add the price of several products on a zen cart categories page in the description.

    For example one categories page needs to list the price of 3 products with product_id 56 57 and 59.

    I would be happy to hard code this, as its only 3 products, however my site is multi-currency so they really need to be dynamic.

    I have been playing around with code for days, my skills are really not up to it. I am suprised I have not found any past posts with the answer. I am starting to think it is a lot harder than I thought

    Any pointers?

    thanks

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Inserting price on non-zen html page on website

    Have you an URL that could better describe what you are trying to accomplish, perrhaps?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Mar 2007
    Location
    Seattle, WA
    Posts
    159
    Plugin Contributions
    0

    Default Re: Inserting price on non-zen html page on website

    Without a URL (and the years of experiance that Ajeh has) I am not going to be much help, however if I needed to accomplish what it sounds like you are attempting, i would see about just pulling the information straight from the database. I have a couple of tools that I have created where I need to display ZenCart information completley outside of ZenCart (info like number of products left and product ID number). I am able to do this with SQL queries straight to the DB and then using PHP to display it in the manner that I need.

    Like I said, not very helpful, but then, it may get you thinking in a new direction so that you can make it work out for you.

  7. #7
    Join Date
    May 2006
    Posts
    80
    Plugin Contributions
    0

    Default Re: Inserting price on non-zen html page on website

    An example URL is:
    http://www.bluesurfart.com/Pop-Art-c-84.html
    This is a sub-category page of the cateogory Art Commission

    The price's are currently static. I want to pull the prices of these specific products. This is just an example. On the main art commission page i want to display a price table for all art commissions, styles and sizes.

    Is there any standard zen code that would grab the price of a certain product? i.e. I can change which product the price is for by editing the product id in the code?

    I don't want to grab the price directly from the sql because then their will be a problem of them not changing when different currencies are selected and I do not know how to do this, so I would rather learn the best way for zen cart.

  8. #8
    Join Date
    May 2006
    Posts
    80
    Plugin Contributions
    0

    Default Re: Inserting price on non-zen html page on website

    Just to clarify there are many reasons why the art commission pages are been made up with a lot of static code and not like standard product listing pages, as seen in the other sections of the site.

    A couple of the reasons:

    1. Once you press buy you will go to a product info page for that size painting. Why? Because there will be an attribute which will accept either the full payment or 50% deposit. This is why have chosen to seperate the sizes as seperate products.

    2. This type of product needs a lot of content, explanations etc. It would not work well if it was displayed like the rest of the site.

  9. #9
    Join Date
    May 2006
    Posts
    80
    Plugin Contributions
    0

    red flag Re: Inserting price on non-zen html page on website

    Does anybody no if there is any zen code that can be used to grab a price for a specific product and insert it into the category description?

    If not what about a template for a custom made page?

    Thanks


  10. #10
    Join Date
    Aug 2005
    Posts
    154
    Plugin Contributions
    0

    Idea or Suggestion Re: Inserting price on non-zen html page on website

    Ok, well I thought I'd finally get this done because I got sick of manually editing my non-Zen static HTML pages, everytime I changed the price in my store!

    Basically all this code does is connect to your ZenCart's database and run a query for the price. I sometimes put my items on special so I also had it run another query to grab that price and show it instead if a product was on special. If you don't have specials then you can cut-down the code, or if you have other things that affect the price you need to know that this code probably won't handle those cases!

    Ok, here are the steps:

    1. Say you have a file called "myStaticPage.html" and that is where you want to insert the Zen prices.

    2. Copy myStaticPage.html to a file called myStaticPage.php. *Note: You can leave out this step if your webserver is set to parse HTML pages as PHP, but usually this is not the case.

    3. Then all you have to do is open the myStaticPage.php file and add this bit of PHP code to the very top of the HTML code that's already there.

    Code:
    <?php
    
    	include("includes/configure.php"); // To grab the DB info
    	$dbh = mysql_connect ("localhost", DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die ('<BR> - Could not connect to the database because: '.mysql_error());
    	mysql_select_db (DB_DATABASE, $dbh) or die(mysql_error( )); 
    
    	$query = <<<EOT
    SELECT `products_id`, `products_price` 
    FROM `zen_products` WHERE (
    `products_id` = 1 || 
    `products_id` = 2 || 
    `products_id` = 3)
    EOT;
    	$result = mysql_query($query); if (!$result) { $message  = "Error! Invalid Query: ".mysql_error()."\n Original Query: ".$query; die($message); }
    	
    	while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
    		$productPrice[$row[0]][0] = $row[1]; // make our own array for the productPrice (I used a multi-dim array because I want to account for specials price and this is the cleanest way I could think of doing this)
    	}
        
        $query = <<<EOT
    SELECT `products_id`, `specials_new_products_price` 
    FROM `zen_specials` WHERE (
    `products_id` = 1 || 
    `products_id` = 2 || 
    `products_id` = 3)
    EOT;
    	$result = mysql_query($query); if (!$result) { $message  = "Error! Invalid Query: ".mysql_error()."\n Original Query: ".$query; die($message); }
    	
    	while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
    		$productPrice[$row[0]][1] = $row[1]; // Now if a specials price exists for a product it will record it in our productPrice array
    	}
        mysql_close();
    
        // Now we have gotten all our data and you would use this code at whatever location in your HTML that you want to show the item's price
        // Of course you can format it however you need, and this probably isn't the cleanest way of doing this
    	echo "<p><B>QUERIED PRICES ARE AS FOLLOWS</B><p>";
    	
    	if (isset($productPrice[1][1])) {
        	echo "Product Item Number 1's price is: <b><span style='text-decoration: line-through;'>".$productPrice[1][0]."</span><br><font color='red'>Sale Price: ".$productPrice[1][1]."</font></b><br>";
    	} else {
    		echo "Product Item Number 1's price is: <b>".$productPrice[1][0]."</b><br>";
    	}
    
    	if (isset($productPrice[2][1])) {
        	echo "Product Item Number 2's price is: <b><span style='text-decoration: line-through;'>".$productPrice[2][0]."</span><br><font color='red'>Sale Price: ".$productPrice[2][1]."</font></b><br>";
    	} else {
    		echo "Product Item Number 2's price is: <b>".$productPrice[2][0]."</b><br>";
    	}
    	
    	if (isset($productPrice[3][1])) {
        	echo "Product Item Number 3's price is: <b><span style='text-decoration: line-through;'>".$productPrice[3][0]."</span><br><font color='red'>Sale Price: ".$productPrice[3][1]."</font></b><br>";
    	} else {
    		echo "Product Item Number 3's price is: <b>".$productPrice[3][0]."</b><br>";
    	}
    	
    	// print_r($productPrice); // Included for test purposes only, used to show the entire array contents	
    ?>
    4. Edit my code to do what you want. Specifically, you'll want to define the product id's for the specific products on your page you want to grab prices for. Also you'll want to not echo the prices as I have done, but place those echo statements in the appropriate spot where the price is supposed to be on your page.

    And that's it!

    Now for some questions for the experts (That means you AJEH!!!):

    Q1: Will this affect my store's performance at all since I am making external queries to the database? I don't think it should because a PHP SQL query is the same no matter where it is executed from, but just thought I should ask.

    Q2: Do you see anything wrong with my code that could cause an security hole or corrupt anything?

    Q3: Any ideas on how to make this more efficient? I know there is DB caching but I'm not familiar with all that.

    Well, I hope this helps everyone, it's gonna make my life easier.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Moving from an established HTML website to Zen
    By FGMJD in forum General Questions
    Replies: 3
    Last Post: 2 Jan 2014, 02:35 PM
  2. How do I make my homepage a non-zen cart page? I want a plain HTML page.
    By bparker in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 20 Sep 2009, 03:57 AM
  3. Display html as website's first page
    By mtkya in forum Basic Configuration
    Replies: 2
    Last Post: 2 Apr 2008, 06:26 PM
  4. Replies: 3
    Last Post: 20 Jan 2008, 11:07 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR