Jump to content

[SOLVED][Help] Carrier depending on the combinations


Grabthesky

Recommended Posts

Hello;

 

I want to hide a carrier depending if in the product list are a product with an expecific combination. 

One posibility is to take the cart product list after showing it to the client and see if there is the expecific combination and the hide one of the carriers, but i dont know how to do that.

 

Thank you.

Edited by Grabthesky (see edit history)
Link to comment
Share on other sites

The code is complicated, but it should be possible. You'll need to add code like the following to the top of order-carrier.tpl in your theme's directory:

{assign var='has_combination' value=false}
{foreach from=$cart->getProducts() item='product'}
    {if $product.id_product_attribute == 13}
        {assign var='has_combination' value=true}
        {break}
    {/if}
{/foreach}

Change 13 to the id_product_attribute of the combination you want to hide the carrier from. You'll need to add more code to check multiple combinations.

 

You can then change the following at around line 70 from:

                            {foreach $option_list as $key => $option}

to:

                            {foreach $option_list as $key => $option}
                                {assign var='hide_carrier' value=false}
                                {foreach $option.carrier_list as $carrier}
                                    {if $carrier.instance->id_reference == 3 && $has_combination}
                                        {assign var='hide_carrier' value=true}
                                        {break}
                                    {/if}
                                {/foreach}
                                {if $hide_carrier}{continue}{/if}

Change 3 to the carrier ID you want to hide.

 

Good luck. I hope it helps.

  • Like 1
Link to comment
Share on other sites

Thank you so much, the help was great but i had to change a thing, the part of the combination id.

 

This is your code

{assign var='has_combination' value=false}
{foreach from=$cart->getProducts() item='product'}
    {if $product.id_product_attribute == 13}
        {assign var='has_combination' value=true}
        {break}
    {/if}
{/foreach}

And this is the code i used

{assign var='has_combination' value=false}
    {foreach from=$cart->getProducts() item='product'}
        {if str_replace (',','',$product.instructions_id) == 29}
            {assign var='has_combination' value=true}
            {break}
        {/if}
    {/foreach}

But it was helpfull.

 

Thank you

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...