Tag: visual studio code

  • Dokan woocommerce, where is {site_name} in email placeholder

    Sometimes can happen that the email sent through woocommerce have incorrect data. Where are placeholders data stored, for instance {site_name}, {site_address}, {order_number}, used in Dokan email templates? And, how to modifify {site_name} placeholder?

    In my case {site_name} placeholder value was referring to an old site name, still present after a migration, due to this I bumped into the necessity of change placeholder value.

    Uno screenshot del file wp-config.php dove รจ presente il prefisso del nome delle tabelle del database.
    A screenshot WordPress wp-config.php file, where the database table prefix is defined.

    To get the job done I was obliged to do the modification at mariadb/mysql database level. More specifically “{site_name}” was defined in “PREFIX_options” table, where PREFIX is your database table prefix defined in wp-config.php file at installation time.

    The option to find out in my case was “woocommerce_email_from_name“, that represents {site_name} placeholder in Dokan email templates.

    I came across it through phpmyadmin search functionality, searching for the name, the wrong one I want to replace, appearing on the email sent to users.

    HINT!

    The aim of this post is to explain how to replace Dokan email template placeholders ({site_name}), if you are trying to customize Dokan email templates, you can check out this link: https://wedevs.com/docs/dokan/tutorials/customize-e-mail-template/

    An example of how Dokan is translating placeholder into bare text is the method trigger, defined in plugins/dokan-pro/modules/rma/includes/emails/class-dokan-rma-send-coupin-email.php php file:

    <?php
    /**
         * Trigger the sending of this email.
         *
         * @param int $product_id The product ID.
         * @param array $postdata.
         */
        public function trigger( $coupon, $data ) {
            if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
                return;
            }
    
            $this->object = $coupon;
    
            if ( $data ) {
                $coupon_id      = isset( $data['request_id'] ) ? $data['request_id'] : '';
                $vendor_id      = isset( $data['refund_vendor_id'] ) ? $data['refund_vendor_id'] : '';
                $vendor         = dokan()->vendor->get( $vendor_id );
                $customer_email = $coupon->get_email_restrictions();
                $customer_email = is_array( $customer_email ) ? $customer_email[0] : $customer_email;
            }
    
            $this->find['site_name']      = '{site_name}';
            $this->find['vendor_name']    = '{vendor_name}';
    
            $this->replace['site_name']   = $this->get_from_name();
            $this->replace['vendor_name'] = $vendor->get_name();
            $this->replace['coupon_id']   = $coupon_id;
    
            $this->setup_locale();
            $this->send( "{$customer_email}, {$this->get_recipient()}", $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
            $this->restore_locale();
        }
    

    In particoular, pay attention at these two lines:

    ...
    $this->find['site_name']      = '{site_name}';
    ...
    $this->replace['site_name']   = $this->get_from_name();
    ...

    The get_from_name method is defined in a superclass and is the function in which the substitution is done.

    I strongly suggest you to explore source code through Visual Studio Code or an equivalent product, to better understand how your specific case works.

    Fell free to post a comment to submit your case.