Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Is there a way to pass the shipping by order total string from the cart config.php to a couchcms repeatable editable in a template to make things easier for client to update without my assistance? Similar to how the discount and tiered pricing strings are in the product template? Maybe it can be in the product template still but under template globals?

Thanks!
The code in cart_ex.php is just a sample and is expected to be modified to suit individual use-cases (will, however, require delving into raw PHP).

If you are OK with doing some custom coding, there is only one line in the existing code (line 111) that gets the value you are interested in from the config file -
Code: Select all
$scale_order_total = $this->get_config( 'shipping_by_order_total' );

Shouldn't be too difficult to make it fetch the value from a global template instead.
Hi KK,

Thank you for pointing me in the right direction. I was able to get every configuration option in cart/config.php into the couch admin. :)

Here is the example specifically for ship_by_order_total, other variables from the config.php can be moved to the couch admin by similar code in the other PHP functions.

First in the cart/index.php (products template), add:

Code: Select all
<cms:globals>
    <cms:editable name='e_cus_shipping_by_order_total' type='message' order='1'>
        <b>Ship by order total:</b><br>
        <font color='#777'>Set the option below if you want to set up a sliding scale of shipping charges based on the order’s total cost.
        For example, if you charge $6 for orders between $1 to $50, $3 for orders between $51 to $100, and free shipping for orders worth $101 and more, set it to</font><br>
        <font color='blue'><pre>[ 0=6 | 50=3 | 100=0 ]</pre></font><br>
        <font color='#777'>where the string above stands for '6 for more than 0, 3 for more than 50, 0 for more than 100'</font><br>
        <font color='#777'>To set up the shipping charges as a percentage of order's total cost (as opposed to fixed values as we did above), add a '%' after the string e.g.</font><br>
        <font color='blue'><pre>[ 0=6 | 50=3 | 100=0 ]%</pre></font><br>
        <font color='#777'>which now makes it 6% of the cart's total for orders over $0, 3% of the cart's total for orders over $50 and 0% (free) for over $100.</font>
    </cms:editable>
    <cms:editable name='cus_shipping_by_order_total' label=':' type='text' validator='regex=/\[\[?([^\]]*)\](\]?)\s*(%?)/' order='2' />
</cms:globals>


Then visit your cart/index.php as superadmin.

Then visit globals and enter the string for the ship by order total and save.

In your cart.ex.php

On line 88 change:
Code: Select all
global $KSESSION;

to
Code: Select all
global $KSESSION, $FUNCS;

On 111 change:
Code: Select all
$scale_order_total = $this->get_config( 'shipping_by_order_total' );

to
Code: Select all
//$scale_order_total = $this->get_config( 'shipping_by_order_total' );
$html = "<cms:get_global 'cus_shipping_by_order_total' masterpage='cart/index.php' />";
$scale_order_total = $FUNCS->embed( $html, $is_code=1 );


Hope someone finds this useful.
Thanks for the update @Blutbaden .
I am sure this will be useful to many of us.
4 posts Page 1 of 1