Ben224 Posted December 20, 2012 Share Posted December 20, 2012 Hello, I am preparing an inventory of sale items for the after Christmas/New Year sales. I would like to update prices by taking a fixed percentage off the existing price for each item under one category. In other words I want to put a whole category on sale at a fixed percentage. After a little head scratching I discovered the following feature in Dashboard > Products > Category Assignment > Update Product Prices - the options are to 'update product prices' by amount or percentage. The feature does not work and any changes I make are not reflected in the front or back end of my store. Can anyone offer any advice that relates to V5? I want to avoid manually going through my products individually to add a sale price. Many thanks in advance. Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 20, 2012 Share Posted December 20, 2012 I'll look into this. Specifically if CC511 has had this fixed in later versions. In the meantime, look at this: Quote Link to comment Share on other sites More sharing options...
Ben224 Posted December 22, 2012 Author Share Posted December 22, 2012 Hi there, Thanks for looking at this. I read your post from the above link. My issue is that CC is not modifying the prices in any way at all and any changes I make to price be it percentage or other are simply being ignored. Appreciate your thoughts. Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 22, 2012 Share Posted December 22, 2012 When you click the checkbox for a product or category, Select "Update selected products (or category)", and enter a small price change, then click Save, what do you notice happens next? Are you doing anything else on this page at the time, or just making one small experiment at changing the price of one product? Do you get the blue Notice bar at the top that "Products have been updated and assigned accordingly"? Or the red Warning bar that says there was no change? Or do you not get any message bar at all? Are you taken back to the Assign to Category page? (I can't imagine what this screen would look like with thousands of products and hundreds of categories.) Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 22, 2012 Share Posted December 22, 2012 I find that there has been some code changes in the Assign to Category function between CC511 and CC514. CC511 does have some logic flow errors -- if you select just a category(s), but no products, nothing gets done and you should receive a warning bar. I suggest you download CC515, find these two files and replace the copies in CC511 with these: /admin/skins/default/templates/products.assign.php /admin/sources/products.assign.inc.php From CC511 to CC515, a selector that lets you choose "what" to update: individual products or all products in a category(s). Additionally, the logic flow has been corrected. Quote Link to comment Share on other sites More sharing options...
Ben224 Posted December 22, 2012 Author Share Posted December 22, 2012 Hi thanks for resolving this. In answer to your second post I hadn't been getting any message at all when I clicked to save. I will replace the files. I had considered an upgrade to the latest CC after the holiday season. I think CC511 is a fairly stable version, at least I have managed with it so far. I wonder if you had any views on the stability of CC515? I guess I'm still a little concerned I may be opening a whole new can of worms by upgrading. Thanks again. Quote Link to comment Share on other sites More sharing options...
rusticc3 Posted January 21, 2014 Share Posted January 21, 2014 I have cc 5.2.5. I have tried the above and i can change all products in a category,but i want to set a sale price to all products in the same category without having to do each one separately. Is this possible? Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 21, 2014 Share Posted January 21, 2014 "I want to set a sale price to all products in the same category." Â For sale prices, I think the Assign to Category (where the ability to update the regular price exists) does not currently have the code to do a massive update on the sale price. Â We would have to add that functionality. Â On the other hand, there was a SQL statement developed that would update prices and/or sale prices to every database record in the inventory table. A search may find it. Â Shortly, I'll look at what it would take to add the code to the Assign to Category page to do the adjustments to the sale price. Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 22, 2014 Share Posted January 22, 2014 Massively updating the sale price seems real easy to do. Let me run some experiments. Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 22, 2014 Share Posted January 22, 2014 In the admin template file products.assign.php, find near line 37: {if isset($CATEGORIES)} Above that, add the following: {* MOD MOD MOD Add feature to bulk update Sale Prices *}    <fieldset><legend>Update Product <span style="color:red;">Sale Prices</span></legend>     <div>       <select name="sale_price[what]">        <option value="products">{$LANG.catalogue.update_checked_products}</option>        <option value="categories">{$LANG.catalogue.update_checked_categories}</option>       </select>       <select name="sale_price[method]">        <option value="fixed">{$LANG.catalogue.update_by_amount}</option>        <option value="percent">{$LANG.catalogue.update_by_percent}</option>       </select>       <select name="sale_price[action]">        <option value="0">{$LANG.common.subtract}</option>        <option value="1">{$LANG.common.add}</option>       </select>       <input type="text" name="sale_price[value]" value="" class="textbox number" />     </div>    </fieldset> {* MOD MOD MOD *} In the admin source file products.assign.inc.php, find: $GLOBALS['main']->setACPNotify($lang['catalogue']['notify_assign_update']); Above that, add the following: // MOD MOD MOD Add feature to bulk update Sale Prices    if($_POST['sale_price']['what']=='products') {       $sale_product_ids = $_POST['product'];    } else {       if($sale_category_products = $GLOBALS['db']->select('CubeCart_category_index',array('DISTINCT' => 'product_id'),array('cat_id' => $_POST['category']))) {          foreach($sale_category_products as $sale_category_product) {             $sale_product_ids[] = $sale_category_product['product_id'];          }       }    }    if (is_array($sale_product_ids) && isset($_POST['sale_price']) && is_array($_POST['sale_price']) && Admin::getInstance()->permissions('products', CC_PERM_EDIT)) {       if (!empty($_POST['sale_price']['value']) && is_numeric($_POST['sale_price']['value'])) {          ## Update prices by x amount/percent          foreach ($sale_product_ids as $sale_product_id) {             if (!is_numeric($sale_product_id)) continue;             if (($sale_product = $GLOBALS['db']->select('CubeCart_inventory', array('sale_price'), array('product_id' => (int)$sale_product_id))) !== false) {                $sale_action   = $_POST['sale_price']['action'];                $sale_price   = $sale_product[0]['sale_price'];                $sale_value   = $_POST['sale_price']['value'];                switch (strtolower($_POST['sale_price']['method'])) {                   case 'percent':                      $sale_shift   = ($sale_action) ? 1 : 0;                      $sale_price   = $sale_product[0]['sale_price'] * (($sale_value/100)+(int)$sale_shift);                      break;                   default:                      $sale_price   += ($sale_action) ? $sale_value : $sale_value-($sale_value*2);                }                $sale_record   = array('sale_price'   => $sale_price);                $GLOBALS['db']->update('CubeCart_inventory', $sale_record, array('product_id' => (int)$sale_product_id));             }          }       }    } // MOD MOD MOD After having selected the product(s) or category(s) (but not both unless you also want to make product<->category assignments), and also having selected what you want to do for the Price -- if anything -- and selecting what you want to do for the Sale Price -- if anything -- click Save. The Price will be updated (if the text field was not empty) and the Sale Price will be updated (if the text field was not empty).  Use only numerical values in these fields -- do not include currency symbols. Quote Link to comment Share on other sites More sharing options...
rusticc3 Posted January 22, 2014 Share Posted January 22, 2014 I have updated both files and the option is available on the admin page, however the new sale prices are not shown against the products and it does not appear to work. I have checked the normal price assign which is working.  these are the files I have changed  Admin/skins/default/template/products.assign.php Admin/sources/products.assign.inc.php, Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 22, 2014 Share Posted January 22, 2014 Please describe the steps you took to update the sale prices. Â On the admin Products, Assign to Category tab, you selected a product(s) or you selected a category(s): Yes/No? You make the appropriate choice in the first selector of the Update Product Sale Prices block: which choice? You made the appropriate choices on the other two selectors and you entered a numerical value in the box: which choices and value? Clicked Save. Did you get the blue banner at the top saying that the assignments were updated: Yes/No? Â Is your store in Sales Mode: Per Product? Quote Link to comment Share on other sites More sharing options...
rusticc3 Posted January 22, 2014 Share Posted January 22, 2014 First i selected a category, then i chose the update the products in the selected category, by amount, subtract .50 Click save - blue header says products updated. Sales item set at per product. The same was done for a product, update selected product, by amount, add .50 Blue header confirms update. I have tried updating normal price products and that works perfectly. Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 22, 2014 Share Posted January 22, 2014 Please, one more test. Â Using phpMyAdmin, browse the CubeCart_inventory table, find a product that you want to change the sale price of. Note its current sale price. Â Use the new functionality in Product Assign to category to change the sale price of that product. Â Back in phpMyAdmin, refresh the the view of the inventory table and find that product. Does the sale price in phpMyAdmin reflect the change? Quote Link to comment Share on other sites More sharing options...
rusticc3 Posted January 22, 2014 Share Posted January 22, 2014 The chosen product has a retail price of 4.99 I have tested three sale price options, firstly reduce item by .50 and 1.00. php admin sales column shows either -.50 or -1.00 I have then tried the same but added 1.00, again the figure in the sales column is 1.00 Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 22, 2014 Share Posted January 22, 2014 From what you describe, the sale price for a particular product, as seen in phpMyAdmin, was initially 0.00. Â Then you caused the sale price to be reduced by 0.50 and phpMyAdmin shows -0.50. Â Then you caused the sale price to be reduced by 1.00 and phpMyAdmin shows -1.00 (but I think should be -1.50). Â Then you caused the sale price to be increased by 1.00 and phpMyAdmin shows 1.00 (but it should be -0.50). Â Or did you cause each change to happen to a different product each time? Â (Hmm... I vaguely recall CubeCart having code that disallows negative sale prices. I don't recall what CubeCart did about it.) Â Choose (or edit) a product that has 20.99 as the price and 13.49 as the sale price. Verify in phpMyAdmin. Â Then, in CubeCart, bulk change that particular product to have a sale price of an increase in the amount by 2.00. Verify in phpMyAdmin. Â Does the product show the expected price and sale price when viewing that product in CubeCart? Quote Link to comment Share on other sites More sharing options...
rusticc3 Posted January 22, 2014 Share Posted January 22, 2014 Hi just to confirm the three action above were independent of each other and not taking off .50 and then a further 1.00, so the 'answers' were correct as such.The sale starting price was 0.00. Â Here are the results from the test. a product was created retail 20.99 and sale price 13.49. the listing in phpadmin reflected this. the website showed the 20.99 with the 13.49 sale price Using the saleprice assign I added 2.00 to the selected item. Â The website reflected this change the sale price was now 15.49, and ofcourse the phpadmin sale price had changed to 15.49. Â so the mod appears to work if there is already a sale price set up. Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 22, 2014 Share Posted January 22, 2014 Which brings up an interesting side-affect of using this bulk price update feature in the Assign to Category screen: Â It will be real easy to set the prices and sale prices into a negative value. Quote Link to comment Share on other sites More sharing options...
rusticc3 Posted January 22, 2014 Share Posted January 22, 2014 I know very little about coding, but it seems to me that if I was creating a spreadsheet,the formula in the cell would say +X [normal price] - Y [discount] = P [ sale price.] at the moment it appears we are just putting the discount [Y] in the 'sale price' cell. - over to you. Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 22, 2014 Share Posted January 22, 2014 This feature is a bulk update (or change), not an absolute value. And this feature affects the sale price column of the inventory table. The sale price column is only used when the store is the Per Product Sale mode. So, entering 1.50 in the field means to add (or subtract) 1.50 from what the price is currently at. It does not mean set the price to 1.50 regardless of what it was before. Â The equation you suggested above is, in fact, the equation CubeCart uses when the store is in Percentage Sale mode. Whatever the regular price of the item, subtract (price * XX/100) to get the sale price. 20 - (20 * 0.1) = 18 (The equation could accommodate a sale percentage of 110%, but that would be foolish.) Quote Link to comment Share on other sites More sharing options...
rusticc3 Posted January 22, 2014 Share Posted January 22, 2014 I understand all that, the question is, why does it work when there is already a sale price but not when there is no sale price set? now we realise what is happening , can it be made to work and create a bulk update by category. Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 22, 2014 Share Posted January 22, 2014 In post#11 where you said, "the new sale prices are not shown against the products and it does not appear to work", to what page of CubeCart are you referring? Â When the database showed -1.00, what CubeCart page did not show -1.00 as the sale price? Â CubeCart will not show an item as being on sale if: the sale price is zero or negative, the sale price is greater than the regular price, and possibly if the logged in customer is getting a better price via their group membership pricing structure. Â CubeCart will show an item is on sale if the sale price is greater than zero and less than the regular price. Â So, if by what you meant "the product's sale price wasn't shown against the product," was when viewing the product on the storefront, then it was Cubecart deciding the item was not on sale and did not show the sale price. Â In admin, when editing a product, on the Pricing tab, CubeCart will show whatever value is recorded in the database (-1.00). Quote Link to comment Share on other sites More sharing options...
rusticc3 Posted January 22, 2014 Share Posted January 22, 2014 Hi We sell keyrings for £2.99. I have tried to use your mod to make a sale price of £2.49. So i highlight the category, keyrings, choose the update products in the selected category,by amount,subtract, 0.50 In phpadmin the sale price for items in the keyring category is showing -.50. The shop is showing the keyrings with a retail price of £2.99, the sale price of £2.49 is not showing. Because the sale price is above zero you say it should be visible. If i choose a keyring and set a sale price in admin product, the shop shows the sale price. When the database showed -1.00, what CubeCart page did not show -1.00 as the sale price? Answer the only place that showed -1.00 was the sale column in the database, the shop only showed the current full retail price.. CubeCart will not show an item as being on sale if: the sale price is zero or negative, the sale price is greater than the regular price, and possibly if the logged in customer is getting a better price via their group membership pricing structure. Answer I enter a number in the sale price box after choosing either Add or Subtract, this number is shown in phpadmin sale price column as +/- entered number, this number does not show anywhere else. CubeCart will show an item is on sale if the sale price is greater than zero and less than the regular price. Answer, this is not happening when i use your mod but only when i set a sale price individually using the standard cc admin product method. So, if by what you meant "the product's sale price wasn't shown against the product," was when viewing the product on the storefront, then it was Cubecart deciding the item was not on sale and did not show the sale price. Answer, on all tests the retail price was 2.99. I set a reduction of .50 and expected to see a sale price of 2.49. (You are telling me cc did not recognise this as a sale price?) In admin, when editing a product, on the Pricing tab, CubeCart will show whatever value is recorded in the database (-1.00). Answer that is correct, if i enter a reduction on a product or category in your sale price mod. The product or products in that category will all show the reduction (-1.00) as the sale price on the pricing tab of admin and not the retail price minus the reduction. ---------------------------------------------------------------------- Hopefully you have all the information to correct the errors. Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 23, 2014 Share Posted January 23, 2014 For the purposes of this feature in the Assign to Category page, one must consider the regular price and sale price as totally disconnected from one another. To further that consideration, instead of price, I will use apples. Â I start with a farm basket full of apples. I don't know, nor do I care, how many apples are currently in the basket. My task is simply to add two apples to the basket. Again, I don't know or care how many were in the basket then, nor how many are in the basket now. Â That's how this feature works. Regardless of the price, I need to add 0.75 to it. I don't need to know the price I end up with. All I needed to do was to increase the price of my items by 0.75. Â The new code treats the sale price exactly the same way as the regular price -- adding or removing some apples to the basket and not caring how many there actually are. Â Â What we can do it create some code that will allow the admin to set a fixed price and sale price. I need to have a farm basket with exactly 249 apples in it. How do I do that? I dump all the apples out then add exactly 249 apples back into the basket. This suggested code will replace the price with whatever is exactly needed. Â Better yet, we can do that with the code already given: 1. Select your category(s). 2. Update products in selected categories 3. By Percent 4. Subtract 5. 100 Â The above steps will subtract 100% of the current sale price from the current sale price. Thus, the new sale price becomes 0.00 and we have zero apples in the basket. Â Next: 1. Re-select your category(s). 2. Update products in selected categories 3. By Amount 4. Add 5. 2.49 Â This will add 2.49 to the current sale price. Technically, we don't care what the current sale price was (but we know it's 0.00). Thus, the new sale price becomes 2.49 and we have 249 apples in the basket. Quote Link to comment Share on other sites More sharing options...
rusticc3 Posted January 23, 2014 Share Posted January 23, 2014 Well i have not clue what you are rambling on about. Would it not be better just to rewrite the mod so that it works. The above is not solution to fix the error. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.