Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
Hi everybody.

I'm trying to develop a small shop online.
I've followed the tutorial on the web, and its almost done.
But I have a question.

On the shop there will be different shipping charges, but not only for the quantity or the total amount. There will be also for the country. Three options: Spain, Europe, the rest of the world.

I've looked for into the forum and I think that there is no the option in the Couch Shopping Cart for changing the shipping charges for different countries.
But anyway, that is my first question:
Can I modify the shipping charges depending on the receiving country?

As I don't think so, here is another question.
I think about to put the different country possibilities as another product. And add it to the cart as the other items. But I want to do that in another step, in the second page of the shop. But when I add this second "item" (the shipping country), this action refresh the cart template, that is the first one. And I want that stay in this second page.
The cart template is the first one, because when I add a item to the cart I want that the same page for selecting the items shows the visitor the cart content. And also I want that behauvior in the second shipping page.

Then I want to know if is possible that if I click the submit input in the pp_product_form, that add the item to the cart, it refresh the present page and it doesn't take back to the cart template.

I hope somebody can understand what is the problem, because it's difficult to me to explain it in my language, harder in english.
Hi,

The cart code provided in the docs is just a sample implementation. It does not account for country in the calculations but with just a bit of effort we can add that. So the alternative solution you proposed won't be needed.

Can you please let me know how the selected country would affect the pricing? Would be something fixed (as a surcharge to the cart) or something else?
Hi KK.

Can you please let me know how the selected country would affect the pricing? Would be something fixed (as a surcharge to the cart) or something else?


What we do with the shop and shipping is that:
Differente prices for the total amount of items in the cart: a price for purchase 5 or less items, and a higher price if the amount is more then 5 items.
And also a price if the delivery is in Spain, another one for Europe, and another one for the rest of the world.
That is 6 different prices:
Spain:
<=5 : 5€
>5 : 8€
Europe:
<=5 : 12€
>5 : 18€
World:
<=5 : 18€
>5 : 20€
(this prices are just an example).

The alternative solution that I explain above use this prices as items in the cart. But for adding that in a second page of the shop, that calculate the total items in the cart and only show the prices for the real situation (if less than 5 one price, if more another price), and we can add that as a product, as another item. And that works fine, it appears in the cart and update the total price. But it takes back to the first page of the shop, and we want that stay in the same.

I hope that this info could be useful for reaching a solution.

Thanks.
Just one question - can we breakdown the charges like the following?

Fixed shipping charges ('shipping_by_quantity_ordered' in config file):
<=5 : 5€
>5 : 8€

plus additional shipping charges based on location:
Spain:
<=5 : 0
>5 : 0

Europe:
<=5 : 7€
>5 : 10€

World:
<=5 : 13€
>5 : 12€

Not a problem if it is not feasible. Just let me know.
Thanks.
Yes, we could breakdown the prices like that, if that make easier the solution.
OK, let us use your original calculations.

As an example solution, I'm attaching a modified 'checkout.php' template (place it with the frontend templates) and 'cart_ex.php' (place it in 'couch/addons/cart' folder).

The checkout will show a dropdown to select the shipping location from while the 'cart_ex.php' will use the selected location to do the calculations.

The solution is a variation of what is explained here -
viewtopic.php?p=18213#p18213

A similar solution can also be found at - viewtopic.php?p=11271#p11271

Basically we add a new form showing the locations on the checkout page (take care not to inadvertently nest this form within the other two forms on the same page) -
Code: Select all
<!-- START CHOOSE SHIPPING LOCATION FORM -->
<div class="coupon-box" style="margin-right:15px;">
    <cms:form method="post" anchor='0'>
        <cms:if k_success >
            <cms:set_session name='selected_shipping_location' value=frm_shipping_location /> 
            <cms:pp_refresh_cart />
            <cms:redirect k_page_link />
        </cms:if>
       
        <div class="styled">
        <cms:input type="dropdown"
            name="shipping_location"
            opt_values="
                Choose shipping location = 0 |
                Spain = 1 |
                Europe (Excluding Spain) = 2 |
                Rest Of The World = 3 "
            opt_selected = "<cms:get_session 'selected_shipping_location' />"
            onchange="this.form.submit()"
        />
        </div>
    </cms:form>
</div>
<!-- END CHOOSE SHIPPING LOCATION FORM -->

And add the following logic to the get_shipping() function in cart_ex.php
Code: Select all
// Check if shipping location selected
$shipping_location = $KSESSION->get_var('selected_shipping_location') ;
if( $shipping_location==1 ){ /* Spain */
    if( $items<=5 ){
        $cost += 5;
    }
    else{
        $cost += 8;
    }
}
elseif( $shipping_location==2 ){ /* Europe */
    if( $items<=5 ){
        $cost += 12;
    }
    else{
        $cost += 18;
    }
}
elseif( $shipping_location==3 ){ /* World */
    if( $items<=5 ){
        $cost += 18;
    }
    else{
        $cost += 20;
    }
}

Hope this helps you in devising your own solution.

Attachments

Absolutely thanks!!!.

I've just change my .php files for those that you attach, and it works really clean.
It's exactly what we are looking for.

Now I will analyse the code carefully for trying to understand how it works. And in the future be able to make modifications.

Thanks a lot.
7 posts Page 1 of 1