Post by trof83 » Thu Jul 14, 2011 3:18 pm

Hey guys I was wondering if someone could help out here. I'm using 1.4.9.4. Ive designed and modified the product controller and tpl to calculate square footage/price and now I need a way to pass that variable off to the cart.

Ive pulled data from model files to the cart before by just adding to array but nothing quite like this since each piece of data is unique and not database driven. If someone can give me a clue as to where to go Id appreciate it.

New member

Posts

Joined
Thu Apr 15, 2010 3:52 pm

Post by rph » Thu Jul 14, 2011 5:36 pm

If you mod /system/library/cart.php price computation changes will populate across the store.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by trof83 » Thu Jul 14, 2011 11:55 pm

Well Ive tried passing it /system/library/cart.php as session data and that works but it only keeps the first price calculated price and doesn't seem to update. Should I be passing this through as something else instead of session data?

New member

Posts

Joined
Thu Apr 15, 2010 3:52 pm

Post by rph » Fri Jul 15, 2011 5:02 am

The only thing OpenCart keeps is product ID, quantity, and options. Stuff like price is always recalculated in the cart->getProducts function.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by trof83 » Fri Jul 15, 2011 1:20 pm

I must be missing something, added the variable to the array which replaces price, but once you click on the product link it disappears.

I have tried using this mod that I found by Qphoria, but the only problem with that is it gives an even dollar amount only, so if its 4.32 it rounds down to 4.00, do the input values get filtered by open cart? Here this is the code at the bottom I replaced input type to hidden instead of text.

Like I said I really appreciate any help thanks.

Code: Select all

1. EDIT: catalog/view/theme/YOURTHEME/template/product/product.tpl

2. FIND: 
--------------------------------------
 <?php if ($display_price) { ?>
 <?php if ($discounts) { ?>
--------------------------------------

3. BEFORE, ADD:
--------------------------------------
              <!-- //Q: START Custom Price -->
              <?php $query = $this->db->query("SELECT sku FROM ".DB_PREFIX."product WHERE product_id = '".$product_id."'"); ?>
              <?php if ($query->row['sku'] == 'custom') { ?>
              <div style="background: #FFFFCC; border: 1px solid #FFCC33; padding: 10px; margin-top: 2px; margin-bottom: 15px;">
                <table style="width: 100%;">
                  <tr>
                    <td>Or... Custom value<br/>
                      <input type="text" name="option[custom]" value=""/>
                    </td>
                  </tr>
                </table>
              </div>
              <?php } ?>
              <!-- //Q: END Custom Price -->
--------------------------------------

4. EDIT: system/library/cart.php

5. FIND:
--------------------------------------
foreach ($options as $product_option_value_id) {
--------------------------------------

6. AFTER, ADD:
--------------------------------------        		 	
        		 	//Q: Custom Price
        		 	if (!is_numeric($product_option_value_id)) {
        		 		$optdata = explode('-', $product_option_value_id);
						if($optdata[1] != '')
						{
							$option_data[] = array(
								'product_option_value_id' => $product_option_value_id,
								'name'                    => $optdata[0],
								'value'                   => $optdata[1],
								'prefix'                  => '+',
								'price'                   => $optdata[1]
							);
							$option_price = $option_price + $optdata[1];
						}
        				continue;
					}//
--------------------------------------

7. FIND:
--------------------------------------
if (!$options) {
--------------------------------------

8. BEFORE, ADD:
--------------------------------------
		//Q: Custom Price
    	if (isset($options['custom'])) {
    		$options['custom'] = ('custom-') . ($options['custom']);
		}//
--------------------------------------

9. For each item you want to support this custom price option, you can set the SKU to "custom" and it will show the input field.

Q

New member

Posts

Joined
Thu Apr 15, 2010 3:52 pm

Post by rph » Fri Jul 15, 2011 2:22 pm

I'm not really sure what you're going for. This is a mod for allowing customers to enter an option price.

I think we need to go back to the beginning. What exactly are you trying to accomplish here?

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by trof83 » Sat Jul 16, 2011 2:46 am

Well I need a way to sell an item by square footage, I have the portion that calculates the price and square footage built in to the product controller, now i just need the cart to catch the actual length, width and price.

New member

Posts

Joined
Thu Apr 15, 2010 3:52 pm

Post by rph » Sat Jul 16, 2011 5:41 am

Can you sell the product per square foot or is this something where the customer enters their own length/width dimensions?

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by harryusa » Sun Jul 17, 2011 10:34 pm

I did this already. Here are the links to the topics I used to figure all this out. Take your time to read through them all even if at first you don't understand it completely. Do it chronilogically starting with my first topic and as you code you will see I went through the same thing. Also, I may or may not have addressed the topic of what fields and tables in the database need to be updated to present a "custom" product to your customer, so you may have to do some work in making it present to them. The MVC model is very versitile once you get a handle on it, which I still struggle with on occasion, certainly the experienced people here can give more guidance. Also, I wish someone would tell me where I could find a description of the database fields and their interaction with each other, for example, while uploading a bunch of products from another source into the database, I found I needed to set the "date created" field to some value before it would show; There are other issues I am trying to figure out yet like where and how to insert all the product image link info into the database as nothing I do currently seems to allow the product I created show an image that I alreadyt put into the image folder using the Admin panel. Anyway here are the links, not necessesarily in order:
http://forum.opencart.com/viewtopic.php?f=24&t=27321
http://forum.opencart.com/viewtopic.php?f=21&t=27550
http://forum.opencart.com/viewtopic.php?f=20&t=27695
http://forum.opencart.com/viewtopic.php?f=21&t=27648
http://forum.opencart.com/viewtopic.php?f=20&t=27880
http://forum.opencart.com/viewtopic.php?f=20&t=28074

New member

Posts

Joined
Mon Feb 21, 2011 12:23 pm
Who is online

Users browsing this forum: thbr02 and 89 guests