Post by tdubs » Sat May 04, 2013 11:36 pm

Could someone create an extension that allows Opencart to change all of the prices store-wide for each multistore?

For example:

DomainA -- base price
DomainB -- + 2.5%
DomainC -- - 2.5%
DomainD -- + 1.75%
DomainE -- + 2.25%

etc.

New member

Posts

Joined
Wed Mar 06, 2013 10:21 pm

Post by dharam81 » Tue May 14, 2013 2:35 am

i need this feature for my store too.

any help?

Active Member

Posts

Joined
Mon Apr 30, 2012 8:26 pm

Post by WilliamBD » Fri May 17, 2013 5:04 am

This sounds like fun - lets see what I can make of it.

Recently I gave the slideshow/manufactures/carousel 'banners' to have an option of which store they will appear on. This would mean you no longer need to create a new layout for each site if all you want to do is change the pictures in the banners.

-----------------
You just want a module called 'Multi-Store Price Change'?

User Interface Options:
Store: <A><B>
Price Increase (%): [text box]

*Disclaimer: I hope I have been as clear as possible and helpful. If you are unsure of anything please ask I will be happy to help - I do frequently watch the posts I have posted in previously.

How to change prices across a whole multi-store, with a baseline price for each product:
http://forum.opencart.com/viewtopic.php ... 24#p406793


Active Member

Posts

Joined
Fri Feb 08, 2013 9:33 pm

Post by WilliamBD » Fri May 17, 2013 7:54 pm

(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

*Disclaimer: I hope I have been as clear as possible and helpful. If you are unsure of anything please ask I will be happy to help - I do frequently watch the posts I have posted in previously.

How to change prices across a whole multi-store, with a baseline price for each product:
http://forum.opencart.com/viewtopic.php ... 24#p406793


Active Member

Posts

Joined
Fri Feb 08, 2013 9:33 pm
Who is online

Users browsing this forum: No registered users and 6 guests