View Single Post
  #9  
Old 02-03-2020, 03:44 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,189
 

Default Re: How to bulk change the price of ALL product

Quote:
Originally Posted by voodoo1967
Is the mod 4.7.11 ready ?

Just ran the install - sql patches success, files uploaded ok, and file changes ok - cleared cache. Created a dummy directory and product. Applied bulk discount - increased by $1

and got this in the admin dashboard :-

* @copyright Copyright (c) 2015 CFL Systems, Inc. All rights reserved. * @license CFL Systems Software License Agreement - https://www.cflsystems.com/software-license-agreement.html * @link https://www.cflsystems.com/products-bulk-prices-for-x-cart-classic.html */if ( !defined('XCART_START') ) { header("Location: ../../"); die("Access denied"); }function csi_get_productcode($pid) { global $sql_tbl; $tbl = 'variants'; $field = 'variantid'; $tmp = func_query_first_cell("SELECT variantid FROM $sql_tbl[pricing] WHERE priceid = '$pid'"); if ($tmp == 0) { $tmp = func_query_first_cell("SELECT productid FROM $sql_tbl[pricing] WHERE priceid = '$pid'"); $tbl = 'products'; $field = 'productid'; } $productcode = func_query_first_cell("SELECT productcode FROM $sql_tbl[$tbl] WHERE $field = '$tmp'"); return $productcode;}if ( $pricing_amount < 0 || !is_numeric($pricing_amount)) { $pricing_amount = 0;}$pricing_amount = floatval($pricing_amount);if ( $pricing_amount == 0 || (empty($cats) && empty($mans))) { $top_message['content'] = func_get_langvar_by_name('txt_bulk_pricing_error') ; $top_message['type'] = 'E'; $mode = ''; func_header_location($current_location . '/admin/products_bulk_pricing.php?err=1');}$join = array();$where = array();if (!empty($mans)) { $mans = implode(',', $mans); $where[] = "$sql_tbl[products].manufacturerid IN ($mans)";}if (!empty($cats)) { $cats = implode(',', $cats); if ($only_main_cat == 'Y') { $where[] = "$sql_tbl[products_categories].categoryid IN ($cats) AND $sql_tbl[products_categories].main = 'Y'"; } else { $where[] = "$sql_tbl[products_categories].categoryid IN ($cats)"; } $join[] = "LEFT JOIN $sql_tbl[products_categories] ON $sql_tbl[products].productid = $sql_tbl[products_categories].productid";}$join = implode(' ', $join);$where = empty($where) ? '' : 'WHERE ' . implode(' AND ', $where);$productids = func_query_column("SELECT $sql_tbl[products].productid FROM $sql_tbl[products] $join $where");unset($where);if (!empty($productids)) { $skipped_products = array(); $where = array(); $where[] = "productid IN (" . implode(',', $productids) . ")"; if (!empty($pricing_wholesale)) { $where[] = 'quantity = 1'; } if (!empty($memberships)) { $memberships = implode(',', $memberships); $where[] = "membershipid IN ($memberships)"; } $where = empty($where) ? '' : 'WHERE ' . implode(' AND ', $where); $priceids = func_query("SELECT priceid, price FROM $sql_tbl[pricing] $where"); if (!empty($priceids)) { foreach ($priceids as $k=>$v) { if ($pricing_type == 'percent') { $diff = $v['price'] * $pricing_amount / 100; } elseif ($pricing_type == 'fixed') { $diff = $pricing_amount; } if ($pricing_direction == 'up') { $newprice = $v['price'] + $diff; } elseif ($pricing_direction == 'down') { $newprice = $v['price'] - $diff; } if (!empty($pricing_round)) { $newprice = round($newprice); } if ($newprice <= 0) { $skipped_products[] = csi_get_productcode($v['priceid']); continue; } db_query("UPDATE $sql_tbl[pricing] SET price = $newprice WHERE priceid = " . $v['priceid']); } foreach ($productids as $p) { func_build_quick_prices($p); func_build_quick_flags($p); } $top_message['content'] = func_get_langvar_by_name('txt_bulk_pricing_updated '); $top_message['type'] = 'I'; $smarty->assign('skipped_products', $skipped_products); } else { $top_message['content'] = func_get_langvar_by_name('txt_bulk_pricing_no_prod ucts'); $top_message['type'] = 'I'; } } else { $top_message['content'] = func_get_langvar_by_name('txt_bulk_pricing_no_prod ucts'); $top_message['type'] = 'I';}func_header_location($current_location . '/admin/products_bulk_pricing.php');




This is spitting out the content of the php file instead of running it.
Check what you have uploaded and that the actual files are php files. Are you running this on a working cart or newly installed test cart? If new make sure the server knows it has to process php files as php files and not just dump their content in the browser.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote