CallMeMike Posted September 19 Share Posted September 19 Hi all! I am looking for a solution for a small business that sells access to live online courses. I would like a specific course to have variants in the form of training start date. However, variants should disappear from the selection list the day before the training begins. I haven't found a plugin that would allow me to limit the time of variants. I also searched in the tickets and events area, but I didn't find anything I could use. Thanks for help. 1 Link to comment Share on other sites More sharing options...
ps8modules Posted September 20 Share Posted September 20 Hi. I don't know of any such module either. This is a rather specific request. Combinations consist of variants. We don't see how you have it figured out now, if you have created a variant with a date .... Please give us more information, a sample of your idea. It is not a problem to create such an extension. It is not complicated and a good programmer can create such a module in an hour. 1 Link to comment Share on other sites More sharing options...
CallMeMike Posted September 20 Author Share Posted September 20 Hi! Thanks for response. There is simple example: 1/ Lets say I'm creating new product: "XXX - Online Training - Entry Level". 2/ I define new attribute called: "Date", and add available training dates (YYYY-MM-DD) as values like that: 3/ In Product edit page i generate variants with available seat limit 4/ Final step - Product page. In the date select, trainings should be visible only to the day before the training begins. Viewing this product on 2024-09-10, visible options should be: [2024-09-11, 2024-09-23, 2024-11-01, 2024-11-09, 2024-11-02]. Viewing this product on 2024-09-11 to 2024-09-22, visible options should be: [2024-09-23, 2024-11-01, 2024-11-09, 2024-11-02]. Viewing this product on 2024-09-23, visible options should be: [2024-11-01, 2024-11-09, 2024-11-02]. etc... Link to comment Share on other sites More sharing options...
ps8modules Posted September 20 Share Posted September 20 (edited) Hi. Thank you for the additional information. No extra module is needed, just a script that will run once a day. Sample: (https://your-shop.pl/myscript.php?token=aBcDeFgHiJkL) <?php header("Access-Control-Allow-Origin: *"); include('./config/config.inc.php'); include('./init.php'); $context = Context::getContext(); $db = Db::getInstance(); $token = 'aBcDeFgHiJkL'; // change it $urlToken = $_GET['token']; if ($token == $urlToken) { $expiredDate = date('Y-m-d', strtotime('+1 day')); $attributeGroupId = 19; // chnage it $where = ' WHERE p.id_product_attribute IS NOT NULL AND a.name <= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 day), \'%Y-%m-%d\') OR name = \''.$expiredDate.'\''; $select = 'SELECT a.id_attribute, p.id_product_attribute FROM '._DB_PREFIX_.'attribute_lang a LEFT JOIN '._DB_PREFIX_.'product_attribute_combination p ON (a.id_attribute = p.id_attribute)' .$where. ' GROUP BY a.id_attribute'; $getExpiredAttributeValues = $db->executeS($select); $toRemove = []; $toRemoveAttribute = []; if ($getExpiredAttributeValues){ // found expired foreach ($getExpiredAttributeValues as $attributeCombination) { if ((int) $attributeCombination['id_attribute'] != 0) { $toRemove[] = (int) $attributeCombination['id_product_attribute']; $toRemoveAttribute[] = (int) $attributeCombination['id_attribute']; } } if (!empty($toRemove)) { foreach ($toRemove as $remove) { $combination = new Combination($remove); $combination->delete(); echo 'Deleted product attribute ID: '.$remove.'<br>'; } } if (!empty($toRemoveAttribute)) { foreach ($toRemoveAttribute as $removeVal) { $db->delete('attribute', 'id_attribute = '.$removeVal); $db->delete('attribute_lang', 'id_attribute = '.$removeVal); $db->delete('attribute_shop', 'id_attribute = '.$removeVal); echo 'Deleted attribute ID: '.$removeVal.'<br>'; } } } } Edited September 20 by ps8modules (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now