Post by guidone » Wed Feb 08, 2017 4:42 am

I'm using multi-store on my Opencart 2.2 with 4 stores on production.
I'm using various vQmod extensions but i need some of these must to work on just one of the 4 stores, is this possible and how? I'm talking about vQmod extensions with just one file in vQmod folder not full Modules i can assign to different stores with Layouts.

Thanx in advance

User avatar
New member

Posts

Joined
Thu Mar 28, 2013 7:39 pm

Post by Johnathan » Wed Feb 08, 2017 7:28 am

I don't think there's any extension that is going to do this for you, because vQmod files are just modifications to core files. You'd need the author of each of those vQmod files to give you the right edits to only active for a single store, or hire someone to do those edits for you.

If you need to find a developer, you should post a request in the OpenCart "Commercial Support" forum, which is checked by a number of OpenCart developers. You can also try checking out the OpenCart "Partners" area.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by guidone » Wed Feb 08, 2017 11:58 am

Johnathan wrote:You'd need the author of each of those vQmod files to give you the right edits to only active for a single store, or hire someone to do those edits for you.
Thank you Johnathan, i was asking if it's technically possible to active a vQmod extension for a single store or i have to convert into a module and assign to Layout.

User avatar
New member

Posts

Joined
Thu Mar 28, 2013 7:39 pm

Post by sculptex » Wed Feb 08, 2017 5:04 pm

As Johnathan says, its not easily done as the file structure of vqmod is common to all multistores. And there so many different types of changes that vqmod can make.

However if you want to change indiviual mods, this is an approach you might take;

A very simple example, in the controller section of the appropriate mod to differentiate the different action for each store, include something like;

Code: Select all

			$url = $_SERVER['SERVER_NAME'];
			switch($url)
			{
				case 'www.mystore1.com':
					//PERFORM TASK e.g.
					$showmod = TRUE;
					$showmsg = "showmod";
					break;
				case 'www.mystore2.com':
					//PERFORM ANOTHER TASK OR DO NOTHING
					$showmod = FALSE;
					break;
			}
Then in the tpl you would put something like

Code: Select all

<?php
if($showmod) {
echo $modmsg;
}
?>

ImageImage


User avatar
Active Member

Posts

Joined
Tue Sep 13, 2011 3:07 am
Location - UK

Post by guidone » Wed Feb 08, 2017 6:04 pm

As i wrote i don't have complete modules with tpl, lang etc... but various single vQmod files, each one do his customization, like this:

Code: Select all

<modification>
    <id><![CDATA[Customizzazione conferma ordine]]></id>
    <version><![CDATA[1.0.0]]></version>
    <vqmver><![CDATA[2.3.0]]></vqmver>
    <author><![CDATA[Yes]]></author>

    <file name="catalog/controller/checkout/confirm.php">
    
        <operation info="Spedizione prevista">
            <search position="before"><![CDATA[
            
            	class ControllerCheckoutConfirm extends Controller { 
            	
            ]]></search>
            <add><![CDATA[
            
            	require_once('yes/assets/function.consegna.php');
				
				
			]]></add>
        </operation>
    
        <operation info="Spedizione prevista">
            <search position="before"><![CDATA[
            
            	$this->data['products'] = array();
            	
            ]]></search>
            <add><![CDATA[
            
            	
				$this->data['text_spedizione_prevista'] = '';
				$arrProdotti = array();
				
				if ( $this->cart->hasProducts() ) 
				{
					$sp_products = $this->cart->getProducts();
					
					foreach ( $sp_products as $sp_product ) 
					{
						$arrProdotti[ $sp_product['model'] ][ 'name' ] =  $sp_product['name'];							
						
						foreach ($sp_product['option'] as $sp_option) 
						{
							$arrProdotti[ $sp_product['model'] ][ 'option_name' ] 		=  $sp_option['name'];
							$arrProdotti[ $sp_product['model'] ][ 'option_value' ] 		=  $sp_option['option_value'];
							$arrProdotti[ $sp_product['model'] ][ 'option_value_id' ] 	=  $sp_option['option_value_id'];
							$arrProdotti[ $sp_product['model'] ][ 'option_id' ] 		=  $sp_option['option_id'];
						}
					}
					
					$this->data['text_spedizione_prevista'] = getSpedizionePrevista( $arrProdotti );
				}
				
				
			]]></add>
        </operation>
        
    </file>

    <file name="catalog/view/theme/*/template/checkout/confirm.tpl">
    
       <operation info="Aggiungi data di spedizione">
            <search position="before"><![CDATA[
            
            	<div class="payment"><?php echo $payment; ?></div>
            	
            ]]></search>
            <add><![CDATA[
            
            	<div class="data_spedizione">
            	
            		<h2>Spedizione prevista</h2>
            		<?php echo $text_spedizione_prevista; ?>
            		<br><br>
            		
            	</div>
            	<script>
            		$(function()
            		{
            			if ( $("input[name='shipping_method']:checked").val() == 'free.free' )
            			{
            				$('#text_spedizione_express').hide();
            				$('#text_spedizione_standard').show();
            			}
            			else 
            			{
            				$('#text_spedizione_standard').hide();
            				$('#text_spedizione_express').show();
            			}
            		});
				</script>
            	
            	
            ]]></add>
        </operation>
        
    </file>
    
</modification>
I was hoping i could assign this extension to just 1 of the 4 stores with a php command like

Code: Select all

if($store_id)


Can you help me on this?

User avatar
New member

Posts

Joined
Thu Mar 28, 2013 7:39 pm

Post by sculptex » Wed Feb 08, 2017 7:56 pm

This mod obviously has other files with it and you would probably need to edit them aswell.

You could try to put the conditional statements around some of the code above like my example but its not just what gets displayed via the tpl file, there may be some other functionality that integrates elsewhere.

For example, this mod could have its own table(s) in the database that links to the orders. So then it may expect there to be an entry for each order and cause problems when there is not.
Or it may have some admin-side functionality that will always be accessed from the default store so the different store logic would not apply. There are too many scenarios to list.

Its may get complex very quickly.

So in this instance, for your example I would look for an established flexible shipping mod that already exists with multistore functionality or ask the mod author to make it multistore compatible. A multistore flexible shipping mod was one of the first mods I sought out for my own multistore, and even though I could have modded it myself using the existing shipping modules with conditional code for each multistore, it was a better investment for me to buy an existing mod and put my time to better use.

If it were a self-contained vqmod with no external files then it would be more feasible to do it like my example.

ImageImage


User avatar
Active Member

Posts

Joined
Tue Sep 13, 2011 3:07 am
Location - UK

Post by guidone » Wed Feb 08, 2017 8:25 pm

Every vQmod file i have paid to developer do a specific work, for my very personal store needs, so i cannot find on marketplace. I was only asking if a single file vQmod extension can be set with some php code to work with just 1 of 4 store in a multi-store enviroment.

In the past, when i was working with 1.5 version, i remember i installed various vQmod extension working on default store only NOT on other stores i had with multi-store, so i think there is a solution for my reverse need.

User avatar
New member

Posts

Joined
Thu Mar 28, 2013 7:39 pm

Post by sculptex » Wed Feb 08, 2017 11:28 pm

Okay, then you could approach changing vqmod.php to use dynamically named paths (perhaps prefixed with the store url) for each of the xml, and caches etc. It currently uses fixed paths for all of these and unfortunately, it would not be a quick patch to change this although it potentially could be done.

You would still have the issue whereby the admin for all multistore reside in the default store, so you might still get problems with that but a well written mod should not break in this circumstance.

So sorry its not a simple resolve for you, I think you may have to pay a developer to do this.

As for previous mods in 1.5 working in only default store, that was a long time ago and mods could have been written in a non-multistore way or even deliberately restricted to default so that would be explained.

ImageImage


User avatar
Active Member

Posts

Joined
Tue Sep 13, 2011 3:07 am
Location - UK

Post by guidone » Thu Feb 09, 2017 8:02 am

i want to pay a developer but before i need to know if it's possible converting old vQmod extensions in modules or i'm in force to work with different themes for different stores

User avatar
New member

Posts

Joined
Thu Mar 28, 2013 7:39 pm

Post by sculptex » Thu Feb 09, 2017 4:23 pm

I tried to send you a PM but not sure if its working

If you visit https://www.sculptex.co.uk/ and raise a ticket, I will propose a solution for you.

ImageImage


User avatar
Active Member

Posts

Joined
Tue Sep 13, 2011 3:07 am
Location - UK

Post by guidone » Sun Mar 12, 2017 4:48 pm

Qphoria suggested me to add in the xml file simply:

if ($this->config->get('config_store_id') == 0) {
... some code here
}

any contraindication?

User avatar
New member

Posts

Joined
Thu Mar 28, 2013 7:39 pm

Post by sculptex » Mon Mar 13, 2017 12:00 am

You could alter all your mods with that, its a briefer version of the example I gave using the $_SERVER['SERVER_NAME'] variable but using store Id instead. My solution to your problem is to have vqmod instance work independently for each url, no code amendments required. Just decide which vqmods to upload for each store. Let me know if you are interested.

ImageImage


User avatar
Active Member

Posts

Joined
Tue Sep 13, 2011 3:07 am
Location - UK

Post by gerstavros » Sun Jul 08, 2018 9:24 pm

guidone wrote:
Sun Mar 12, 2017 4:48 pm
Qphoria suggested me to add in the xml file simply:

if ($this->config->get('config_store_id') == 0) {
... some code here
}

any contraindication?
How exactly did you use that?

New member

Posts

Joined
Mon Apr 04, 2016 12:44 am
Who is online

Users browsing this forum: Google [Bot] and 207 guests