osCommerce and osCMax shopping cart software forums

Shopping Cart Software

osCommerce with teeth!

 

Compatability oscommerce contribs for OSCMax

This is a discussion on Compatability oscommerce contribs for OSCMax within the osCMax v2 Customization/Mods forums, part of the osCMax v2.0 Forums category; Originally Posted by met00 For example, here is the edit product for our admin - you can see that it ...


Go Back   osCommerce and osCMax shopping cart software forums > osCMax v2.0 Forums > osCMax v2 Customization/Mods

Register FAQ Members List Calendar Mark Forums Read


Free community membership! Fast easy FREE membership
Reply

 

LinkBack Thread Tools
  #11  
Old 11-13-2007, 05:36 PM
MindTwist's Avatar
Active Member
 
Join Date: Jun 2007
Location: Barcelona, Spain
Posts: 315
Thanks: 8
Thanked 26 Times in 25 Posts
Rep Power: 3
MindTwist will become famous soon enoughMindTwist will become famous soon enough
Default Re: Compatability oscommerce contribs for OSCMax

Quote:
Originally Posted by met00 View Post
For example, here is the edit product for our admin - you can see that it has extended the standard product information quite a bit. (yes we do have a "monthly profit report" that uses the cost basis field, and yes, when you do a "special" it advises the margin and profit decrease and carries that to the report. And no, that one isn't getting released as an add-on.)

Hi met00,
I have just added the Margin Report contribution to my store, looking good so far. I see you have made some addition on your categories.php that makes it show right there the margin in amount and %, could I please borrow that code from you...??
__________________
MindTwist of Twisted Reality and Twisted Tienda
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12  
Old 11-14-2007, 02:22 AM
Active Member
 
Join Date: Oct 2005
Location: wherever I happen to be at the moment
Posts: 444
Thanks: 3
Thanked 75 Times in 70 Posts
Rep Power: 6
met00 is just really nicemet00 is just really nicemet00 is just really nicemet00 is just really nice
Default Re: Compatability oscommerce contribs for OSCMax

Ummm, Margin Report is NOT from me so I have no idea what fields they call from the database (we modified the code to meet our needs as margin report didn't).

Below is the code where we add costs and compute margin...

Code:
<? // MOD: added MSRP ?>
         <tr bgcolor="#ebebff">
            <td class="main"><?php echo TEXT_PRODUCTS_PRICE_MSRP; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_msrp', $pInfo->products_msrp); ?></td>
          </tr>
          <tr bgcolor="#ebebff">
            <td class="main"><?php echo TEXT_PRODUCTS_PRICE_NET; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_price', $pInfo->products_price, 'onKeyUp="updateGross()"'); ?></td>
          </tr>
          <tr bgcolor="#ebebff">
            <td class="main"><?php echo TEXT_PRODUCTS_PRICE_GROSS; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_price_gross', $pInfo->products_price, 'OnKeyUp="updateNet()"'); ?></td>
          </tr>
<?
$margin = $pInfo->products_price - $pInfo->products_cost;
if ($pInfo->products_price != 0) $marginp = (1 - ( $pInfo->products_cost / $pInfo->products_price )) * 100;
if ($margin < .01 ) $margin = "<font color=red>".$margin."</font>";
?>
         <tr bgcolor="#ebebff">
            <td class="main"><?php echo TEXT_PRODUCTS_PRICE_COST; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_cost', $pInfo->products_cost); ?> <i>Margin: <?echo $margin; ?> (<?echo sprintf('%01.2f',$marginp); ?>%)</i></td>
          </tr>
Hope that helps.
__________________
so endith the lesson
<think>sometimes I just sit's and thinks</think>
"Here you are with a hand full of holes, a thumb up your ass, and a big grin to pass the time of day with." - TWB
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to met00 For This Useful Post:
MindTwist (11-14-2007)
  #13  
Old 11-14-2007, 04:54 AM
MindTwist's Avatar
Active Member
 
Join Date: Jun 2007
Location: Barcelona, Spain
Posts: 315
Thanks: 8
Thanked 26 Times in 25 Posts
Rep Power: 3
MindTwist will become famous soon enoughMindTwist will become famous soon enough
Default Re: Compatability oscommerce contribs for OSCMax

It will, I will be able to work it out from that, thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14  
Old 11-14-2007, 08:40 AM
MindTwist's Avatar
Active Member
 
Join Date: Jun 2007
Location: Barcelona, Spain
Posts: 315
Thanks: 8
Thanked 26 Times in 25 Posts
Rep Power: 3
MindTwist will become famous soon enoughMindTwist will become famous soon enough
Default Re: Compatability oscommerce contribs for OSCMax

That did the trick, I hardly had to change anything since my variables are the same.

I thought that the shown margin would update real time like the prices do (you change the net price, and the gross price will change to show your price + taxes), guess I hoped for too much I will try to make it work that way
and let you know.

Thx!
__________________
MindTwist of Twisted Reality and Twisted Tienda
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15  
Old 11-14-2007, 10:01 AM
MindTwist's Avatar
Active Member
 
Join Date: Jun 2007
Location: Barcelona, Spain
Posts: 315
Thanks: 8
Thanked 26 Times in 25 Posts
Rep Power: 3
MindTwist will become famous soon enoughMindTwist will become famous soon enough
Default Re: Compatability oscommerce contribs for OSCMax

So here is my solution, now the info gets updated real-time as you change any of the values, gross value, net value, or product cost:



Here I created updateMargin, and added a call to the function on updateGross and updateNet, so if the net or gross values change, the margins will do so too.

PHP Code:
function updateGross() {
  var 
taxRate getTaxRate();
  var 
grossValue document.forms["new_product"].products_price.value;

  if (
taxRate 0) {
    
grossValue grossValue * ((taxRate 100) + 1);
  }

  
document.forms["new_product"].products_price_gross.value doRound(grossValue4);
  
updateMargin();
}

function 
updateNet() {
  var 
taxRate getTaxRate();
  var 
netValue document.forms["new_product"].products_price_gross.value;

  if (
taxRate 0) {
    
netValue netValue / ((taxRate 100) + 1);
  }

  
document.forms["new_product"].products_price.value doRound(netValue4);
  
updateMargin();
}

function 
updateMargin() {
  var 
netValue document.forms["new_product"].products_price.value;
  var 
costValue document.forms["new_product"].products_cost.value;

  
document.getElementById('margin').innerHTML=doRound(netValue costValue,2);
  
document.getElementById('margin_pct').innerHTML=doRound( (costValue*100)/netValue 2);

And here is the HTML part used before the PRICE_NET and PRICE_GROSS parts:

PHP Code:
  <tr bgcolor="#ebebff">
    <td class="main"><?php echo TEXT_PRODUCTS_PRICE_COST?></td>
    <td class="main"><?php echo tep_draw_separator('pixel_trans.gif''24''15') . '&nbsp;' tep_draw_input_field('products_cost'$pInfo->products_cost'onKeyUp="updateMargin()"'); ?> <i>Margen: <label id="margin"></label> (<label id="margin_pct"></label>%)</i></td>
  </tr>
Also, a little bit down there is this piece of code:

PHP Code:
<script language="javascript"><!--
updateGross();
updateMargin();
//--></script> 
I added the updateMargin() there, so the margins will be shown on page load.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
postaffiliatepro code compatability ? fatbloke osCMax v2 Customization/Mods 1 01-18-2007 06:31 AM
OSCommerce Contribs that work spottedhaggis osCMax v2 Customization/Mods 0 02-20-2006 06:14 PM
Adding Contribs using BTS mattdpeterson osCMax v1.7 General Mods Discussion 0 05-23-2004 02:59 PM
Using Contribs??? WebMistress osCommerce 2.2 Modification Help 12 04-20-2004 08:54 AM
Contribs - can I use a contrib straight from oscommerce jloyzaga osCMax v1.7 Discussion 2 09-17-2003 12:31 AM


All times are GMT -8. The time now is 11:32 AM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO
http://www.oscmax.com/forums/
Copyright 2008 osCMax