Forum for discussing general topics related to Couch.
5 posts Page 1 of 1
Hello Couch friends :)

The aim is to be able to make promotional campaigns for certain products with Shopping Cart.
In other words - Item level discounts like Black Friday Discounts.
Of course we have an editable region pp_discount_scaleр, but he can not be allowed globally (for example through a check box on a page with global settings)
Here's my idea - In my template products.php I made these changes:
before:
Code: Select all
<cms:editable 
            name='pp_discount_scale'
            label=':'
            type='text'
            group='group_price'
            validator='regex=/\[\[?([^\]]*)\](\]?)\s*(%?)/'
            order='23'
        />


after:
Code: Select all
<cms:editable 
            name='pp_discount_scale_normal'
            label=':'
            type='text'
            group='group_price'
            validator='regex=/\[\[?([^\]]*)\](\]?)\s*(%?)/'
            order='23'
        />   
      
      <cms:editable
            name='pp_discount_scale_promo'
            label=':'
            type='text'
            group='group_price'
            validator='regex=/\[\[?([^\]]*)\](\]?)\s*(%?)/'
            order='23'
        />   
      
      
... ...
</cms:template>


<cms:set my_promotional_campaigns_for_certain_products="<cms:get_custom_field 'promotional_campaigns_for_certain_products' masterpage='global_settings.php' 'global' />" />

<cms:if my_promotional_campaigns_for_certain_products="yes" >
<cms:set pp_discount_scale="<cms:show pp_discount_scale_promo/>" scope='global' />
</cms:if>

<cms:if my_promotional_campaigns_for_certain_products="no" >
<cms:set pp_discount_scale="<cms:show pp_discount_scale_normal/>" scope='global' />
</cms:if>


So could make promotional campaigns for a number of products periodically without requiring changes to individual cloned pages!
But this code is not working ... can anyone help?
I do not dare to seek Mr. KK, because he is very busy with Couch version 2

Thanks in advance!
Isn't it possible to make a field called on-sale, filled with a percentage number 50 for 50% and then an if statement for showing the new price and/or extra banner and so on.

something in the line if on-sale exists reduce original price by on-sale percentage.
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
The aim is to manage the global campaign for individual products.
For example, I have 1000 products but only 50 are in promotion, the same promotion is repeated often and it's good for it to be allowed globally and not as editable page of each product

I think it is useful to all Couch users and will be happy to have a solution!
@orbital,

Please try the following -

1. If not already done so, rename 'cart_ex.example.php' to 'cart_ex.php'.
2. Edit 'cart_ex.php' to find the following line (line 38) in 'function pre_calc()' -
Code: Select all
$discount_scale = $this->items[$key]['discount_scale']; // e.g. [ 5=10 | 10=15 ]

3. Delete the line above and replace it with the following -
Code: Select all
global $FUNCS;
$code = "<cms:get_custom_field 'promotional_campaigns_for_certain_products' masterpage='global_settings.php' 'global' />";
$is_promotion_on = trim( $FUNCS->embed($code, 1) );

if( $is_promotion_on=='yes' ){
    $discount_scale = $this->items[$key]['discount_scale_promo']; // e.g. [ 5=10 | 10=15 ]
}
else{
    $discount_scale = $this->items[$key]['discount_scale_normal']; // e.g. [ 5=10 | 10=15 ]
}

I think you'll recognize that this is the PHP version of your code. The [$key]['discount_scale_promo'] and [$key]['discount_scale_normal'] above contain the values of the editable regions 'pp_discount_scale_promo' and 'pp_discount_scale_normal' that you defined in the template.

Please test the code and let me know it it helps.
Thank you very much KK! :) :)
As always your decision is perfectly.

Thank you
5 posts Page 1 of 1