(In Testing)
This will allow you to create as stated above:
Default domain: base price.
- Domain1: Change % of prices across the whole store. (e.g. +5%)
- Domain2: Change % of prices across the whole store. (e.g. -30%)
<<< Please let me know what you think. >>>
Step 1. - Lets add in the label that will display in the Store 'Settings' first.
File: admin->language->english->settings->store.php
After: (Lets keep things tidy)
Code: Select all
$_['entry_layout'] = 'Default Layout:';
Add:
Code: Select all
$_['entry_site_product_increase'] = 'Please enter how much you want to increase products by on this store (e.g. 1.5 is +50%, 1.05 is +5%, 0.5 is -50%). The default value should be 1.';
Step 2. -Lets add this input field to the Store 'Settings'.
File: admin->view->template->setting->store_form.tpl
After: (Around line 1.04)
Code: Select all
<tr>
<td><?php echo $entry_layout; ?></td>
<td><select name="config_layout_id">
<?php foreach ($layouts as $layout) { ?>
<?php if ($layout['layout_id'] == $config_layout_id) { ?>
<option value="<?php echo $layout['layout_id']; ?>" selected="selected"><?php echo $layout['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $layout['layout_id']; ?>"><?php echo $layout['name']; ?></option>
<?php } ?>
<?php } ?>
</select></td>
</tr>
Add: (Before the <table>)
Code: Select all
<tr>
<td><span class="required">*</span> <?php echo $entry_site_product_increase; ?></td>
<td><input type="text" name="config_site_product_increase" value="<?php echo $config_site_product_increase; ?>" />
</tr>
Step 3. - Need to add these variables to the controller
File: admin->controller->setting->store.php
After: (Around line 207)
Code: Select all
$this->data['entry_layout'] = $this->language->get('entry_layout');
Add:
Code: Select all
$this->data['entry_site_product_increase'] = $this->language->get('entry_site_product_increase');
Step 3a.- continuing in controller
File: same file.
After: (Around line 485)
Code: Select all
if (isset($this->request->post['config_layout_id'])) {
$this->data['config_layout_id'] = $this->request->post['config_layout_id'];
} elseif (isset($store_info['config_layout_id'])) {
$this->data['config_layout_id'] = $store_info['config_layout_id'];
} else {
$this->data['config_layout_id'] = '';
}
Add:
Code: Select all
if (isset($this->request->post['config_site_product_increase'])) {
$this->data['config_title'] = $this->request->post['config_site_product_increase'];
} elseif (isset($store_info['config_site_product_increase'])) {
$this->data['config_site_product_increase'] = $store_info['config_site_product_increase'];
} else {
$this->data['config_site_product_increase'] = '';
}
*If you save all you have done so far and go to your settings in another store (not the default one) you should now see the input box there. This value will now save and will be saved in the database. But the prices of products will not change yet.
Step 4. - Now lets update the product price on the store
File: catalog->model->catalog->product.php
After: (Around line 14)
Code: Select all
$query = $this->db->query("SELECT DISTINCT...
Add:
Code: Select all
$store_price_change_query = $this->db->query("SELECT value FROM " . DB_PREFIX ."setting WHERE `store_id` = '" . (int)$this->config->get('config_store_id') . "' AND `key` LIKE 'config_site_product_increase'");
if ($store_price_change_query->num_rows) {
$price_change = $store_price_change_query->row['value'];
}
else {
$price_change = '1';
}
Step 4a.
File: same file
Change: (Around line 47)
Code: Select all
'price' => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']),
To:
Code: Select all
'price' => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']) * $price_change,
*Now if you view the product on another store it will change the price, if you set a different value than '1' for the option of the store in the previous steps.
Step 5. - Changing Cart in Library
File: system->library->cart.php
After: (Around line 163)
Code: Select all
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getCustomerGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
Add:
Code: Select all
$store_price_change_query = $this->db->query("SELECT value FROM " . DB_PREFIX ."setting WHERE `store_id` = '" . (int)$this->config->get('config_store_id') . "' AND `key` LIKE 'config_site_product_increase'");
if ($store_price_change_query->num_rows) {
$price_change = $store_price_change_query->row['value'];
}
else {
$price_change = '1.5';
}
Step 5a. - Change one last line
File: same as before
Change: (Just after the code you just added / Line 173)
Code: Select all
$price = $product_query->row['price'];
To:
Code: Select all
$price = $product_query->row['price']*$price_change;
----------------------------------------
That should be it. Please let me know what you think of the above. This does not allow you to change the default store from the original prices however. Just other stores.
Suggestions:
- Not allow the % to go below -50%
- Check for valid input of a number