Forum Replies Created

Viewing 15 replies - 1 through 15 (of 21 total)
  • Thread Starter crownst

    (@crownst)

    Hi Herman (@bsfherman),

    Thanks for your response. Unfortunately, the issue still persists. When I set the column layout to 1 under Customizer > WooCommerce > Product Catalog in the mobile view, it has no effect, and two columns are still displayed.

    To clarify, the problem is not understanding what the setting does, but that the setting itself does not seem to be applying correctly. Do you have any insight into why this might be happening and how it can be resolved?

    If custom CSS is needed, could you please provide the exact code and steps for implementing it to ensure that only one product per row is displayed in mobile view?

    Thank you for your assistance.

    Thread Starter crownst

    (@crownst)

    That worked. I did not have activated the two options attach to email and delete file after upload activated under advanced. Sorry, I didn’t know that I had to activate this manually after the mu plugin code was uploaded. Thank you very much for the help!

    Thread Starter crownst

    (@crownst)

    Hi,

    So I don’t get an error message. I just see on the server that the attachments are still being saved on the server.

    Export: https://file.io/7b0GcrlWjJ7C

    Example: /wp-content/uploads/forminator/21718_25d7468ddd30f55e02f2f8d69ef3b5ba/uploads/EMt9PiJrCAur-sdfsda.pdf


    I added this code under “/wp-content/mu-plugins/forminator-send-file-as-an-attachment-in-email.php“:

    <?php
    
    if ( ! class_exists( 'WPMUDEV_Frominator_Upload_Email_Attachment' ) ) {
        
        class WPMUDEV_Frominator_Upload_Email_Attachment {
    
            public $attachments                 = array();
            public $attachments_to_delete       = array();
            private static $_instance           = null;
           
            public static function get_instance() {
    
                if( is_null( self::$_instance ) ){
                    self::$_instance = new WPMUDEV_Frominator_Upload_Email_Attachment();
                }
                return self::$_instance;
                
            }
    
            private function __construct() {
    
                add_filter( 'wp_mail', array( $this, 'filter_email_args' ) );
                add_filter( 'forminator_field_upload_general_settings', array( $this, 'add_attachment_settings' ) );
    
                add_action( 'forminator_custom_form_submit_before_set_fields', array( $this, 'manage_field_data' ), 20, 3 );
                add_action( 'forminator_custom_form_mail_after_send_mail', array( $this, 'delete_uploaded_files' ) );
    
            }
    
            public function add_attachment_settings( $settings ) {
    
                $attachment_option = array(
                        'type'          => 'Toggle',
                        'label'         => 'Attach to email',
                        'name'          => 'use_as_attachment'
                    );
                $delete_upload_option = array(
                        'type'          => 'Toggle',
                        'label'         => 'Delete file after upload',
                        'name'          => 'delete_uploaded_file'
                    );
    
                array_push( $settings, $attachment_option, $delete_upload_option );
    
                return $settings;
    
            }
    
            public function manage_field_data( $entry, $form_id, $data ) {
    
                foreach ( $data as $key => $field_data ) {
    
                    if ( ! isset( $field_data['name'] ) ) {
                        continue;
                    }
    
                    $field = Forminator_API::get_form_field( $form_id, $field_data['name'] );
    
                    if ( is_wp_error( $field ) ) {
                        continue;
                    }
    
                    $field_type    = Forminator_Field::get_property( 'type', $field );
    
                    if ( 'upload' != $field_type ) {
                        continue;
                    }
                    
                    if( !is_array( $field_data[ 'value' ][ 'file' ][ 'file_path' ] ) ){
                        if ( $file_path = $field_data[ 'value' ][ 'file' ][ 'file_path' ] ) {
                            
                            if ( Forminator_Field::get_property( 'use_as_attachment', $field ) ) { 
                                unset( $this->attachments );                  
                                $this->attachments[] = $file_path;
                            }
    
                            if ( Forminator_Field::get_property( 'delete_uploaded_file', $field ) ) {                    
                                $this->attachments_to_delete[] = $file_path;
                            }
    
                        }
                    } else {
                        unset( $this->attachments );
                        foreach( $field_data[ 'value' ][ 'file' ][ 'file_path' ] as $fi_k => $fi_val ){
    
                            if ( Forminator_Field::get_property( 'use_as_attachment', $field ) ) {   
                                $this->attachments[] = $fi_val;
                            }
    
                            if ( Forminator_Field::get_property( 'delete_uploaded_file', $field ) ) {                    
                                $this->attachments_to_delete[] = $fi_val;
                            }
    
                        }
                    }
    
                }
    
            }
    
            public function filter_email_args( $mail_args ) {
    
                if ( ! empty( $this->attachments ) ) {
                    $mail_args[ 'attachments' ] = $this->attachments;
                }
    
                return $mail_args;
            }
    
            public function delete_uploaded_files() {
                
                if ( ! empty( $this->attachments_to_delete ) ) {
                    foreach ( $this->attachments_to_delete as $file_path ) {
                        unlink( $file_path );
                    }
                }
            }
        }
    
        if ( ! function_exists( 'wpmudev_forminator_upload_email_attachment' ) ) {
    
            function wpmudev_forminator_upload_email_attachment() {
                return WPMUDEV_Frominator_Upload_Email_Attachment::get_instance();
            };
    
            add_action( 'plugins_loaded', 'wpmudev_forminator_upload_email_attachment', 10 );
        }
    
    }

    But here no ID of the form is included, like in the first code: https://gist.github.com/wpmudev-sls/7a32dc5407324cc902f8b9ad8970ef62

    Thread Starter crownst

    (@crownst)

    Thanks for the new code. Unfortunately this doesn’t work for multiple file uploads. Is there a way to find out what the problem is from an error log? Or did it work in your tests?

    Thread Starter crownst

    (@crownst)

    Thanks for the tip about the mu plugin. That basically worked. Multiple files are allowed when uploading files. If several falls are uploaded, an error message appears in the form frontend “An error occurred while processing the form. Please try again” and a 500 Internal Server Error in the DEV console. The error with the multiple file upload only occurs if the mu plugin is activated. Does anything need to be adjusted in the mu plugin so that it works with multiple file uploads? If only one file is uploaded, then it works with the mu plugin code. Unfortunately not with several files. Thanks for the efforts.

    Thread Starter crownst

    (@crownst)

    Oh my god, how could I have missed that. You saved my life! ??

    Thread Starter crownst

    (@crownst)

    Thread Starter crownst

    (@crownst)

    “Before starting the database update this time, did you check to confirm that there are no new jobs stuck in the Action Scheduler queue? (I’m aware you had cleared the old pending ones yesterday by executing those manually.)”

    I deleted the old ones manually.

    Thread Starter crownst

    (@crownst)

    Sorry, I expressed myself wrong. No, I did not update WooCommerce or DB on the live site. I just scheduled a post on the live site to see if the cron jobs are working. The post was published on the live page as planned – but not on the staging page.

    I wanted to test whether the cron jobs work on the live side. I think the contribution planning works with a cron job. So I wanted to test it this way.

    Thread Starter crownst

    (@crownst)

    Now I’ve tested it on the live page with a scheduled post. It worked there without any problems. The task was not displayed to me in the planned actions. However, the page was published at the allotted time. Very strange that it doesn’t work on the staging environment. Maybe it’s really because the staging site was provided with a password by the hoster.

    Thread Starter crownst

    (@crownst)

    Hi,

    I want to give you an update again. The database version is unfortunately still the old one.

    WooCommerce Datenbank Version: 6.4.0
    WooCommerce-Version: 6.7.0

    -> https://ibb.co/hmt2856
    -> https://ibb.co/ZSFH5Gm

    Unfortunately I have no more idea what to do. Does the DB update take longer than a day or two?

    I wanted to test the cron job with a scheduled post. Put the page online at 07:55. After I saved the page and set the time, the post (page) showed that it was scheduled for 07:55. However, under Tools / Scheduled Actions and the Pending tab, I could still see 15 pending tasks. Actually, there should be 16 tasks. I waited until 07:55 and the post was not published. So I’m sure there is a problem with the cron.

    –> https://ibb.co/mC7bwMR

    Kind regards.

    • This reply was modified 2 years, 4 months ago by crownst.
    Thread Starter crownst

    (@crownst)

    Hi,

    i have checked the file wp-cron.php. Here i can find “define( ‘DOING_CRON’, true );” So i think this is okay.
    –> https://ibb.co/DRFn4xH

    This file wp-config.php does not contain anything with “cron” – the cron jobs are not disabled here either.

    Thank you.

    Thread Starter crownst

    (@crownst)

    Hi again,

    WooCommerce version: 6.7.0 -> https://ibb.co/pxk69n7

    WooCommerce Database version: 6.4.0 -> https://ibb.co/Ld4RzDZ

    thank you.

    Thread Starter crownst

    (@crownst)

    Hi again,

    I have now started the DB update again.
    Updated at: 10:32 AM

    However, the entry in the jobs has a time of 08:32:50 –> https://ibb.co/4WcsMsZ

    So my time was 10:32 | WooCommerce time was 08:32:50. Maybe a problem?

    Thread Starter crownst

    (@crownst)

    I just deleted the cronjobs from “52 years ago”.

    But I think if I run update database again now, the job will not run again. Do you have any other ideas what I can do or test?

    Thank you very much for your help!

Viewing 15 replies - 1 through 15 (of 21 total)