Promotions Scheduling mod

Regarding the requests to allow only a single DOTD Product Feature:

My “[now]” tag equates to PHP’s time() function which is the current time down to the second. CS-Cart’s date picker stores the date as a UNIX Timestamp (also precise to the second) but rounds off the hours/minutes/seconds to 0. This means that with your Promotion Conditions setup for only a single “equals” comparison, your DOTD is only valid for the 1st second of the date selected.



I’ve been trying to figure out how to round time() to the day (like the cart does) so I can add “[today]”, but all I’ve done is given myself a headache.



Glen

Thanks for putting in the time and effort. A lot of us were going to put in a good amount of money to have this mod completed by the CS team.



I’ve tried every which way to incorporate this into a block. NO LUCK!



If I knew how to link a graphic to the deal of the day product details page, I would create the graphic and countdown clock for everyone. I’m just not that well versed with this carts template system or syntax. I know how to change the price display by using {if $product.discount} do this {else} do that {/if}, but that’s about all I’ve got. There has to be a way to link products to active promotions. I thought the active promotions page would have something, and it does not.



I can deal with the current set up of begin date and end date, but I need (I’m sure everyone needs) an active link that directs a viewer to the product details page.

Regarding the creation of a DOTD block:

I’ve investigated the new “Shop by Features” addon and that isn’t going to be a solution for this. What we really need is a new “Filling: Filters” type for “Products” blocks.

-Glen

FYI - I’d like to keep the DOTD discussion in the original thread. The mod above could be used for promotions unrelated to DOTD.



thanks,

Glen

I am testing this out now.



In regards to the date issue, if you only want it to run for one day you would select a start date as 3/5/2010 with an end date as 3/6/2010, for instance. In the backend, this is telling the store to start it at midnight on 3/5/2010 and end it at midnight on 3/6/2010, so it is only 24 hours.

I think I figured out how to put products in their own special category if they are within the start and end dates of this mod. Test at your own risk. :wink: NOTE: This only adds the special category during the duration of the promotion - it doesn’t remove it from existing categories.



I created a “Deal of the Day” category. You’ll need to note the category_id for new category you create. In my example, the category_id is 143.



You’ll also need to go into Product Features to find out the feature_id numbers of the start date and end date fields. Just mouse over the edit link for those features to find this information. In my example, the start date feature_id is 6 and the end date feature_id is 7.



Here are the mysql commands that you can set up in a daily cron job.



This one will add the product to the new category where start date is some time in the past. Replace 143 with your new category_id and replace 6 with the feature_id for your begin date:

INSERT INTO cscart_products_categories (product_id,category_id,link_type,position) SELECT product_id,[COLOR="Red"]143[/COLOR],'A',0 FROM cscart_product_features_values WHERE feature_id = '[COLOR="Red"]6[/COLOR]' AND value_int <= unix_timestamp();


This command will remove the products from the new category where the end date is some time in the past. Replace 7 with the feature_id for your end date and replace 143 with the category_id for your new category:

DELETE FROM cscart_products_categories WHERE product_id IN (SELECT product_id FROM cscart_product_features_values WHERE feature_id = '[COLOR="Red"]7[/COLOR]' AND value_int <= unix_timestamp()) AND category_id = [COLOR="Red"]143[/COLOR];




I am pretty sure these will take care of adding products when their promotion starts and remove products after their promotion has ended. It seems to be working in my preliminary tests. :smiley:



ETA: maybe someone else can come up with a cleaner way of doing it. This adds all products with a start date in the past and then removes the ones that have expired. I couldn’t get that first command to work with a date range. I’ll keep playing around with it. I had a lot of distractions when I was working on it. (i.e. two kids and a crazy dog)

Im sure this one work, but its a bit tricky, can you do some template edit with this ogia?

using assign var something

[quote name=‘vidan’]Im sure this one work, but its a bit tricky, can you do some template edit with this ogia?

using assign var something[/QUOTE]

What is tricky about it? Maybe I can explain.



You put these commands into a cron job that will run daily. It has to be run daily so it can update which products will go into the category. No template edits means you don’t have to do anything in an upgrade. (just the original edits Glen posted to make the original mod work)

Setting up a cron job is dead-simple (in Cpanel, at least) but it feels a bit like a hack because it lives outside of CS-Cart. Personally, I’m a convert to cron thanks to Ogia’s persistence.