CGhoST Posted July 4, 2016 Share Posted July 4, 2016 Hi Everyone I installed http://addons.oscommerce.com/info/9346 It an addon that shows the margin/markup for each product. The problem with this addon is the percentage only updates after you save the product and edit the product again. The following is the javascript for this: /* COST MARGIN MOD START OF CODE ADDITION */ function updateMargin() { var grossValue = document.forms["new_product"].products_price.value; var costValue = document.forms["new_product"].products_cost.value; marginValue = parseInt(-100 + (grossValue/costValue)*100); document.getElementById('products_price_margins').innerHTML = marginValue + "%"; } /* COST MARGIN MOD END OF CODE ADDITION */ Can someone please assist in showing how: document.getElementById('products_price_margins').innerHTML = marginValue + "%"; can be changed so that it does a live update just the way gross and net value change if you change either. Link to comment Share on other sites More sharing options...
♥14steve14 Posted July 4, 2016 Share Posted July 4, 2016 If you cant get that to work try using this addon. its been updated recently, and works on my BS version of oscommerce. http://addons.oscommerce.com/info/8147 REMEMBER BACKUP, BACKUP AND BACKUP Link to comment Share on other sites More sharing options...
Mikepo Posted July 4, 2016 Share Posted July 4, 2016 I agree with the last post, margin report addon 8147 works well with BS. Mike osC CE live - developing osC Phoenix adding modules with no core changes(awesome and easy!) Link to comment Share on other sites More sharing options...
Bob Terveuren Posted July 4, 2016 Share Posted July 4, 2016 Hi Looking at the install for your version: %%%Replace With: <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') . ' ' . tep_draw_input_field('products_cost', $pInfo->products_cost, ''); ?></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') . ' ' . tep_draw_input_field('products_price', $pInfo->products_price, 'onKeyUp="updateGross()"'); ?></td> </tr> try swapping in this %%%Replace With: <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') . ' ' . tep_draw_input_field('products_cost', $pInfo->products_cost, 'onKeyUp="updateMargin()"'); ?></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') . ' ' . tep_draw_input_field('products_price', $pInfo->products_price, 'onKeyUp="updateGross()"'); ?></td> </tr> i.e. add a call to the updateMargin() function - it looks like it is missing? Link to comment Share on other sites More sharing options...
CGhoST Posted July 5, 2016 Author Share Posted July 5, 2016 Thank you Bob. That worked great. I tried http://addons.oscommerce.com/info/8147 but it didn't show percentage in product edit. But i see that part can be added from the contribution i installed. Is it possible it can be changed into a field so that if there is a cost and you set a certain markup the net price changes with it? Link to comment Share on other sites More sharing options...
CGhoST Posted July 5, 2016 Author Share Posted July 5, 2016 This contribution works fine also .. both addons are similar and have very similar code except this one doesn't have margin report whereas the other one does. Link to comment Share on other sites More sharing options...
CGhoST Posted July 6, 2016 Author Share Posted July 6, 2016 Ok i tried to make a pull down menu to select margin or markup to see the percentage. This is what i did. <tr bgcolor="#ebebff"> <td class="main"><?php echo TEXT_PRODUCTS_COST_SELECTION; ?></td> <?php $margin_array[] = array('id' => '1', 'text' => 'Margin'); $margin_array[] = array('id' => '2', 'text' => 'Markup'); ?> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('margin_array', $margin_array);?></td> </tr> The IF statement line is what i am not understanding. Following is the code i have: if ($_GET['margin_array'] == '1'){ function updateMargin() { var realValue = document.forms["new_product"].products_price.value; var costValue = document.forms["new_product"].products_cost.value; marginValue = parseInt(-100 + (realValue/costValue)*100); document.getElementById('products_price_margins').innerHTML = marginValue + "%"; } } if ($_GET['margin_array'] == '2'){ function updateMargin() { var grossValue = document.forms["new_product"].products_price.value; var costValue = document.forms["new_product"].products_cost.value; marginValue = parseInt(100 - (costValue/grossValue)*100); document.getElementById('products_price_margins').innerHTML = marginValue + "%"; } } Please help Link to comment Share on other sites More sharing options...
CGhoST Posted July 8, 2016 Author Share Posted July 8, 2016 Can someone please assist with the IF statement. Will be much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.