Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    3
    Plugin Contributions
    0

    Default Re: Subscription Add on Module

    Thank you for the detail.

  2. #2
    Join Date
    Jan 2013
    Posts
    3
    Plugin Contributions
    0

    Default Re: Subscription Add on Module

    I found this plug in for subscriptions.

    https://zucando.com/zen-cart-modules...s-for-zen-cart

    Might be what I am looking for.

    Dave

  3. #3
    Join Date
    Nov 2020
    Posts
    310
    Plugin Contributions
    1

    Default Re: Subscription Add on Module

    Quote Originally Posted by dave1!dave View Post
    I found this plug in for subscriptions.

    https://zucando.com/zen-cart-modules...s-for-zen-cart

    Might be what I am looking for.

    Dave
    Just came across this whilst looking for something that would allow me to create a social club and unfortunately the module you linked too is no longer available, anyone happen to have the files for that module still after all these years??

    my other option is to use the following ai generated "module" that to me looks like it is missing a few steps...

    Code:
    <?php
    /**
     * Soundbyte Social Club Membership Module
     * This module integrates membership signup, management, and QR code generation into a Zen Cart store.
     */
    
    // Ensure secure execution
    define('IS_ADMIN_FLAG', true);
    
    // Include necessary libraries
    require_once(DIR_FS_CATALOG . '/vendor/phpqrcode/qrlib.php');
    
    class MembershipModule {
    
        /**
         * Create membership as a product
         */
        public static function addMembershipProduct() {
            global $db;
    
            $membershipProduct = [
                'products_name' => 'Soundbyte Social Club Membership',
                'products_description' => 'Become a member of the Soundbyte Social Club and enjoy exclusive benefits, including music events and trading card tournaments!',
                'products_price' => 20.00,
                'products_tax_class_id' => 1,
                'products_status' => 1,
                'products_quantity' => 9999,
                'products_date_added' => 'NOW()',
            ];
    
            // Insert product into database
            zen_db_perform(TABLE_PRODUCTS, $membershipProduct);
    
            // Assign product to a specific category (optional)
            $productId = $db->Insert_ID();
            zen_db_perform(TABLE_PRODUCTS_TO_CATEGORIES, [
                'products_id' => $productId,
                'categories_id' => 1 // Replace with actual category ID for memberships
            ]);
        }
    
        /**
         * Create a new database table to store membership details
         */
        public static function createMembershipTable() {
            global $db;
            
            $sql = "CREATE TABLE IF NOT EXISTS club_members (
                        member_id INT AUTO_INCREMENT PRIMARY KEY,
                        customer_id INT NOT NULL,
                        membership_start_date DATETIME NOT NULL,
                        membership_status ENUM('Pending', 'Active', 'Expired') DEFAULT 'Pending',
                        waiting_period_end_date DATETIME NOT NULL,
                        qr_code_path VARCHAR(255),
                        FOREIGN KEY (customer_id) REFERENCES customers(customers_id)
                    ) ENGINE=InnoDB;";
            $db->Execute($sql);
        }
    
        /**
         * Handle membership purchase
         */
        public static function handleMembershipPurchase($customerId) {
            global $db;
    
            $startDate = date('Y-m-d H:i:s');
            $waitingPeriodEndDate = date('Y-m-d H:i:s', strtotime('+48 hours'));
    
            // Generate QR Code
            $qrData = "MemberID: $customerId | StartDate: $startDate";
            $qrFileName = DIR_FS_CATALOG . "images/membership_qr_$customerId.png";
            QRcode::png($qrData, $qrFileName, QR_ECLEVEL_H, 10);
    
            // Insert membership details into the database
            $db->Execute("INSERT INTO club_members (customer_id, membership_start_date, membership_status, waiting_period_end_date, qr_code_path)
                          VALUES ('$customerId', '$startDate', 'Pending', '$waitingPeriodEndDate', '$qrFileName')");
    
            // Notify customer
            self::sendMembershipEmail($customerId, $qrFileName, $waitingPeriodEndDate);
        }
    
        /**
         * Send membership confirmation email
         */
        private static function sendMembershipEmail($customerId, $qrFileName, $waitingPeriodEndDate) {
            global $db;
    
            // Fetch customer email
            $customerQuery = $db->Execute("SELECT customers_email_address, customers_firstname FROM customers WHERE customers_id = '$customerId'");
            $email = $customerQuery->fields['customers_email_address'];
            $firstName = $customerQuery->fields['customers_firstname'];
    
            // Email content
            $subject = "Welcome to Soundbyte Social Club";
            $message = "Dear $firstName,\n\nThank you for joining the Soundbyte Social Club!\n\n" .
                       "Your membership is now active. Please note that alcohol privileges will be available after $waitingPeriodEndDate.\n\n" .
                       "Attached is your digital membership card with a QR code for quick verification.\n\nEnjoy exclusive events, music, and more!\n\nBest regards,\nSoundbyte Social Club";
    
            // Attach QR Code
            $attachment = chunk_split(base64_encode(file_get_contents($qrFileName)));
            $boundary = "==Boundary" . md5(time());
    
            $headers = "From: [email protected]\r\n" .
                       "MIME-Version: 1.0\r\n" .
                       "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n\r\n" .
                       "--$boundary\r\n" .
                       "Content-Type: text/plain; charset=UTF-8\r\n\r\n" .
                       "$message\r\n\r\n" .
                       "--$boundary\r\n" .
                       "Content-Type: image/png; name=\"membership_qr_$customerId.png\"\r\n" .
                       "Content-Disposition: attachment; filename=\"membership_qr_$customerId.png\"\r\n" .
                       "Content-Transfer-Encoding: base64\r\n\r\n" .
                       "$attachment\r\n--$boundary--";
    
            // Send email
            mail($email, $subject, '', $headers);
        }
    
        /**
         * Display membership QR code in customer account page
         */
        public static function displayMembershipQRCode($customerId) {
            global $db;
    
            $query = $db->Execute("SELECT qr_code_path FROM club_members WHERE customer_id = '$customerId'");
            if ($query->RecordCount() > 0) {
                echo '<div><h3>Your Membership QR Code</h3>';
                echo '<img src="' . DIR_WS_CATALOG . $query->fields['qr_code_path'] . '" alt="Membership QR Code">';
                echo '</div>';
            } else {
                echo '<p>No active membership found. Join the Soundbyte Social Club today!</p>';
            }
        }
    }
    
    // Initialization
    MembershipModule::createMembershipTable();
    MembershipModule::addMembershipProduct();
    I spotted the db query looks wrong and that is probably the least of the issues, usually takes a while to edit these into something that works

 

 

Similar Threads

  1. v155 Monthly subscription plugin/module
    By amebb in forum General Questions
    Replies: 2
    Last Post: 9 Apr 2019, 11:18 AM
  2. newsletter subscription module default to html
    By tbrides in forum All Other Contributions/Addons
    Replies: 10
    Last Post: 13 Dec 2008, 02:26 AM
  3. Newsletter Subscription Module - Quick question please?
    By blind1 in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 23 Jan 2007, 01:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg