osCmax v2.5 User Manual
Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

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 ...

      
  1. #11
    Active Member MindTwist's Avatar
    Join Date
    Jun 2007
    Location
    Barcelona, Spain
    Posts
    409
    Rep Power
    7


    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...??

  2. #12
    osCMax Development Team met00's Avatar
    Join Date
    Oct 2005
    Location
    wherever I happen to be at the moment
    Posts
    854
    Blog Entries
    2
    Rep Power
    26


    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

  3. #13
    Active Member MindTwist's Avatar
    Join Date
    Jun 2007
    Location
    Barcelona, Spain
    Posts
    409
    Rep Power
    7


    Default Re: Compatability oscommerce contribs for OSCMax

    It will, I will be able to work it out from that, thanks!

  4. #14
    Active Member MindTwist's Avatar
    Join Date
    Jun 2007
    Location
    Barcelona, Spain
    Posts
    409
    Rep Power
    7


    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!

  5. #15
    Active Member MindTwist's Avatar
    Join Date
    Jun 2007
    Location
    Barcelona, Spain
    Posts
    409
    Rep Power
    7


    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.

Page 2 of 2 FirstFirst 12

Similar Threads

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

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
  •