Set price based on country



  • Hi, for example I have some country arrays, how could I set the price depending on the country?
    For example, I use this function but I don't get the location from the country basket.
    How can I proceed?

    $area1 = 'Hungary';
            
            $area2 = array('Czechia', 'Slovakia', 'Slovenia', 'Bulgaria', 'Serbia');
            
            $area3 = array('Poland', 'Germany', 'Switzerland', 'Netherlands',
                            'Liechtenstein', 'Austria', 'Italy', 'Croatia');
                            
            $area4 = array('Denmark', 'France', 'United Kingdom', 'Irland', 'San Marino',
                            'Vatican', 'Mocano', 'Portugal', 'Spain', 'Canary Islands');
                            
            $area5 = array('Greece', 'Andorra', 'Gibraltar', 'Sweden', 'Finland', 'Norway',
                            'Malta', 'Cyprus', 'Estonia', 'Lithuania', 'Latvia', 'Turkey');
    
            switch ($cart->shipping_address->country)
            {
                case $area1:
                    $object->base_price = 18;
                break;
    
                case array_search($cart->shipping_address->country, $area2):
                    $object->base_price = 18;
                break;
    
                case array_search($cart->shipping_address->country, $area3): 
                    $object->base_price = 8;
                break;
    
                case array_search($cart->shipping_address->country, $area4): 
                break;
    
                case array_search($cart->shipping_address->country, $area5): 
                break;
            }
    

    Or I tried with ifs but it doesn't work, I get error 500 when I want to post.
    He may not find the country.
    How would you proceed to set a price depending on the country?



  • Hi @DaniD,

    This is something that you are customizing and you should be familiar with the basics. If you want some customization you can contact Webkul for support.


Log in to reply