نمایش یادداشت بعد از اتمام سفارش برای مشتری

yas_persian

تازه وارد
سلام. تو نسخه 2.1 ووکامرس این گزینه رو تو بخش تنظیمات ووکامرس نمیبینم. چطور باید یادداشت برای مشتری بزارم؟ میخوام بعد از اینکه پرداخت کرد یه یادداشت براش ظاهر شه از طرف مدیریت.

 

alifiresoft

کاربر عضو
توی تنظیمات ووکامرس باید باشه. یه اسکرین شات بزار از قسمت مدیریت ووکامرست.

 

yas_persian

تازه وارد
توی تنظیمات ووکامرس باید باشه. یه اسکرین شات بزار از قسمت مدیریت ووکامرست.
You must be registered for see images attach


از کدوم قسمتش اسکرین شات بزارم؟ این بخش تسویه حسابه، زیر این که تو عکس نیفتاده درگاه های پرداخت هست.

 

Mohammad

مدیر انجمن
پرسنل مدیریت
از چه درگاهی استفاده می کنید؟

 

Mohammad

مدیر انجمن
پرسنل مدیریت
لطفا تاپیک پشت سر هم نزنید... من هر روز سرمیزنم به تاپیک ها...

فایل index.php درگاه پی لاین رو باز کنید

قسمتی که نوشته:


کد:
$order -> add_order_note('پرداخت انجام شد<br/>کد پیگیری: '.$trans_id .' AND '.$id_get );
میتونید تبدیل کنید به:


کد:
                                         $order -> add_order_note('پرداخت انجام شد<br/>کد پیگیری: '.$trans_id .' AND '.$id_get.'<br/> سلام. این پیغام منه' );
جایی که نوشته شده. سلام این پیغام منه رو هر چی دوست دارید بنویسید

 

yas_persian

تازه وارد
لطفا تاپیک پشت سر هم نزنید... من هر روز سرمیزنم به تاپیک ها...فایل index.php درگاه پی لاین رو باز کنید

قسمتی که نوشته:


کد:
$order -> add_order_note('پرداخت انجام شد<br/>کد پیگیری: '.$trans_id .' AND '.$id_get );
میتونید تبدیل کنید به:


کد:
                                         $order -> add_order_note('پرداخت انجام شد<br/>کد پیگیری: '.$trans_id .' AND '.$id_get.'<br/> سلام. این پیغام منه' );
جایی که نوشته شده. سلام این پیغام منه رو هر چی دوست دارید بنویسید
آقا محمد این کارو کردم ولی جواب نداد. دوتا جا به این شکل داره. کپی کردم ببینید:


کد:
{
                                    $this -> msg['message'] = "پرداخت شما با موفقیت انجام شد<br/>کد پیگیری: $trans_id ";
                                    $this -> msg['class'] = 'success';
                                        $order -> payment_complete();
$order -> add_order_note('پرداخت انجام شد<br/>کد پیگیری: '.$trans_id .' AND '.$id_get );
                                        $order -> add_order_note($this->msg['message']);
                                        $woocommerce -> cart -> empty_cart();
        }else
        {
        $this -> msg['class'] = 'error';
        $this -> msg['message'] = "پرداخت با موفقيت انجام نشد";
        }
 

Mohammad

مدیر انجمن
پرسنل مدیریت
فایلی که استفاده می کنید رو اینجا بزارید (فایلی که تغییرات توش دادید)

 

Mohammad

مدیر انجمن
پرسنل مدیریت
کد:
<?php
/*
Plugin Name: درگاه پرداخت Payline ووکامرس
Plugin URI: http://woocommerce.ir
Description: پرداخت آنلاین فروشگاه ساز ووکامرس با درگاه Payline . طراحی شده توسط <a target="_blank" href="Http://www.woocommerce.ir">پشتیبان رسمی ووکامرس</a>
Version: 3.2
Author: Woocommerce Persian
Author URI: http://woocommerce.ir
Copyright: 2014 Woocommerce.ir
 */

add_action('plugins_loaded', 'woocommerce_payline_init', 0);

function woocommerce_payline_init() {

    if ( !class_exists( 'WC_Payment_Gateway' ) ) return;

if($_GET['msg']!=''){
        add_action('the_content', 'showMessagepayline');
    }

    function showMessagepayline($content){
            return '<div class="box '.htmlentities($_GET['type']).'-box">'.base64_decode($_GET['msg']).'</div>'.$content;
    }
    class WC_Payline extends WC_Payment_Gateway {
    protected $msg = array();
        public function __construct(){
            // Go wild in here
            $this -> id = 'payline';
            $this -> method_title = __('درگاه Payline', 'payline');
            $this -> has_fields = false;
            $this -> init_form_fields();
            $this -> init_settings();
            $this -> title = $this -> settings['title'];
            $this -> description = $this -> settings['description'];
            $this -> merchant_id = $this -> settings['merchant_id'];
            $this -> vahed = $this -> settings['vahed'];
            $this -> redirect_page_id = $this -> settings['redirect_page_id'];
            $this -> msg['message'] = "";
            $this -> msg['class'] = "";
            add_action( 'woocommerce_api_wc_payline', array( $this, 'check_payline_response' ) );
            add_action('valid-payline-request', array($this, 'successful_request'));


            if ( version_compare( WOOCOMMERCE_VERSION, '2.0.0', '>=' ) ) {
                add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
             } else {
                add_action( 'woocommerce_update_options_payment_gateways', array( $this, 'process_admin_options' ) );
            }

            add_action('woocommerce_receipt_payline', array($this, 'receipt_page'));
        }

        function init_form_fields(){

            $this -> form_fields = array(
                'enabled' => array(
                    'title' => __('فعال سازی/غیر فعال سازی', 'payline'),
                    'type' => 'checkbox',
                    'label' => __('فعال سازی درگاه پرداخت Payline', 'payline'),
                    'default' => 'no'),
                'title' => array(
                    'title' => __('عنوان:', 'payline'),
                    'type'=> 'text',
                    'description' => __('عنوانی که کاربر در هنگام پرداخت مشاهده می کند', 'payline'),
                    'default' => __('پرداخت اینترنتی Payline', 'payline')),
                'description' => array(
                    'title' => __('توضیحات:', 'payline'),
                    'type' => 'textarea',
                    'description' => __('توضیحات قابل نمایش به کاربر در هنگام انتخاب درگاه پرداخت', 'payline'),
                    'default' => __('پرداخت از طریق درگاه Payline با کارت های عضو شتاب', 'payline')),
                'merchant_id' => array(
                    'title' => __('شناسه API درگاه', 'payline'),
                    'type' => 'text',
                    'description' => __('API درگاه را وارد کنید')),
                'vahed' => array(
                    'title' => __('واحد پولی'),
                    'type' => 'select',
                    'options' => array(
                    'rial' => 'ریال',
                    'toman' => 'تومان'
                    ),
                    'description' => "نیازمند افزونه ریال و تومان هست"),
                'redirect_page_id' => array(
                    'title' => __('صفحه بازگشت'),
                    'type' => 'select',
                    'options' => $this -> get_pages('انتخاب برگه'),
                    'description' => "ادرس بازگشت از پرداخت در هنگام پرداخت"
                )
            );


        }

        public function admin_options(){
            echo '<h3>'.__('درگاه پرداخت Payline', 'payline').'</h3>';
            echo '<p>'.__('درگاه پرداخت اینترنتی Payline').'</p>';
            echo '<table class="form-table">';
            $this -> generate_settings_html();
            echo '</table>';

        }


        function payment_fields(){
            if($this -> description) echo wpautop(wptexturize($this -> description));
        }

        function receipt_page($order){
            echo '<p>'.__('با تشکر از سفارش شما. در حال انتقال به درگاه پرداخت...', 'payline').'</p>';
            echo $this -> generate_payline_form($order);
        }

        function process_payment($order_id){
            $order = &new WC_Order($order_id);
            return array('result' => 'success', 'redirect' => $order->get_checkout_payment_url( true )); 
        }

       function check_payline_response(){
            global $woocommerce;
        $order_id = $woocommerce->session->zegersot;
        $order = &new WC_Order($order_id);
        if($order_id != ''){
        if($order -> status !='completed'){
        $url = 'http://payline.ir/payment/gateway-result-second';
        $api=$this -> merchant_id;
        $trans_id = $_POST['trans_id']; 
        $id_get = $_POST['id_get']; 
        $result = $this ->get($url,$api,$trans_id,$id_get); 
        if($result == 1 AND $woocommerce->session->zegersot_id==$id_get)
        {
                                    $this -> msg['message'] = "پرداخت شما با موفقیت انجام شد<br/>کد پیگیری: $trans_id <br/> سلام. این پیغام مدیر هستش... ";
                                    $this -> msg['class'] = 'success';
                                        $order -> payment_complete();
                                        $order -> add_order_note('پرداخت انجام شد<br/>کد پیگیری: '.$trans_id .' AND '.$id_get.'سلام این پیغام دوم مدیر هستش' );
                                        $order -> add_order_note($this->msg['message']);
                                        $woocommerce -> cart -> empty_cart();
        }else
        {
        $this -> msg['class'] = 'error';
        $this -> msg['message'] = "پرداخت با موفقيت انجام نشد";
        }
            }else{
            $this -> msg['class'] = 'error';
        $this -> msg['message'] = "قبلا اين سفارش به ثبت رسيده يا صفارشي موجود نيست!";
            }
            }
                $redirect_url = ($this -> redirect_page_id=="" || $this -> redirect_page_id==0)?get_site_url() . "/":get_permalink($this -> redirect_page_id);
                $redirect_url = add_query_arg( array('msg'=> base64_encode($this -> msg['message']), 'type'=>$this -> msg['class']), $redirect_url );

                wp_redirect( $redirect_url );
                exit;
            }




        function showMessage($content){
            return '<div class="box '.$this -> msg['class'].'-box">'.$this -> msg['message'].'</div>'.$content;
        }


        public function generate_payline_form($order_id){
            global $woocommerce;
            $order = new WC_Order($order_id);
            $redirect_url = ($this -> redirect_page_id=="" || $this -> redirect_page_id==0)?get_site_url() . "/":get_permalink($this -> redirect_page_id);
            $redirect_url = add_query_arg( 'wc-api', get_class( $this ), $redirect_url );
            unset( $woocommerce->session->zegersot );
            unset( $woocommerce->session->zegersot_id );
            $woocommerce->session->zegersot = $order_id;
            $url = 'http://payline.ir/payment/gateway-send'; 
            $api=$this -> merchant_id;
            $amount = $order -> order_total; 
            if($this -> vahed=='toman')
            $amount = $amount*10;
            $redirect = urlencode($redirect_url); 
            $result = $this ->send($url,$api,$amount,$redirect); 
            if($result > 0 && is_numeric($result)){ 
            $woocommerce->session->zegersot_id=$result;
            $go = "http://payline.ir/payment/gateway-$result"; 
            header("Location: $go"); 
            }else if($result=='-1'){
            echo "api ارسالي با نوغ api تعريف شده در payline سازگار نيست";
            }else if($result=='-2'){
            echo "مقدار مبلغ نبايد کمتر از 1000 ريال باشد";
            }else if($result=='-3'){
            echo "error";
            }else if($result=='-4'){
            echo "درگاهي با اطلاعات ارسالي شما يافت نشده و يا در حالت انتظار مي باشد";
            }


        }

private function send($url,$api,$amount,$redirect){ 
    $ch = curl_init(); 
    curl_setopt($ch,CURLOPT_URL,$url); 
    curl_setopt($ch,CURLOPT_POSTFIELDS,"api=$api&amount=$amount&redirect=$redirect"); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 
    $res = curl_exec($ch); 
    curl_close($ch); 
    return $res; 
}
    private function get($url,$api,$trans_id,$id_get){ 
    $ch = curl_init(); 
    curl_setopt($ch,CURLOPT_URL,$url); 
    curl_setopt($ch,CURLOPT_POSTFIELDS,"api=$api&id_get=$id_get&trans_id=$trans_id"); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 
    $res = curl_exec($ch); 
    curl_close($ch); 
    return $res; 
} 
        function get_pages($title = false, $indent = true) {
            $wp_pages = get_pages('sort_column=menu_order');
            $page_list = array();
            if ($title) $page_list[] = $title;
            foreach ($wp_pages as $page) {
                $prefix = '';
                // show indented child pages?
                if ($indent) {
                    $has_parent = $page->post_parent;
                    while($has_parent) {
                        $prefix .=  ' - ';
                        $next_page = get_page($has_parent);
                        $has_parent = $next_page->post_parent;
                    }
                }
                // add to page list array array
                $page_list[$page->ID] = $prefix . $page->post_title;
            }
            return $page_list;
        }

    }


    function woocommerce_add_payline_gateway($methods) {
        $methods[] = 'WC_Payline';
        return $methods;
    }

    add_filter('woocommerce_payment_gateways', 'woocommerce_add_payline_gateway' );
}

?>
 

yas_persian

تازه وارد
کد:
<?php
/*
Plugin Name: درگاه پرداخت Payline ووکامرس
Plugin URI: http://woocommerce.ir
Description: پرداخت آنلاین فروشگاه ساز ووکامرس با درگاه Payline . طراحی شده توسط <a target="_blank" href="Http://www.woocommerce.ir">پشتیبان رسمی ووکامرس</a>
Version: 3.2
Author: Woocommerce Persian
Author URI: http://woocommerce.ir
Copyright: 2014 Woocommerce.ir
 */

add_action('plugins_loaded', 'woocommerce_payline_init', 0);

function woocommerce_payline_init() {

    if ( !class_exists( 'WC_Payment_Gateway' ) ) return;

if($_GET['msg']!=''){
        add_action('the_content', 'showMessagepayline');
    }

    function showMessagepayline($content){
            return '<div class="box '.htmlentities($_GET['type']).'-box">'.base64_decode($_GET['msg']).'</div>'.$content;
    }
    class WC_Payline extends WC_Payment_Gateway {
    protected $msg = array();
        public function __construct(){
            // Go wild in here
            $this -> id = 'payline';
            $this -> method_title = __('درگاه Payline', 'payline');
            $this -> has_fields = false;
            $this -> init_form_fields();
            $this -> init_settings();
            $this -> title = $this -> settings['title'];
            $this -> description = $this -> settings['description'];
            $this -> merchant_id = $this -> settings['merchant_id'];
            $this -> vahed = $this -> settings['vahed'];
            $this -> redirect_page_id = $this -> settings['redirect_page_id'];
            $this -> msg['message'] = "";
            $this -> msg['class'] = "";
            add_action( 'woocommerce_api_wc_payline', array( $this, 'check_payline_response' ) );
            add_action('valid-payline-request', array($this, 'successful_request'));


            if ( version_compare( WOOCOMMERCE_VERSION, '2.0.0', '>=' ) ) {
                add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
             } else {
                add_action( 'woocommerce_update_options_payment_gateways', array( $this, 'process_admin_options' ) );
            }

            add_action('woocommerce_receipt_payline', array($this, 'receipt_page'));
        }

        function init_form_fields(){

            $this -> form_fields = array(
                'enabled' => array(
                    'title' => __('فعال سازی/غیر فعال سازی', 'payline'),
                    'type' => 'checkbox',
                    'label' => __('فعال سازی درگاه پرداخت Payline', 'payline'),
                    'default' => 'no'),
                'title' => array(
                    'title' => __('عنوان:', 'payline'),
                    'type'=> 'text',
                    'description' => __('عنوانی که کاربر در هنگام پرداخت مشاهده می کند', 'payline'),
                    'default' => __('پرداخت اینترنتی Payline', 'payline')),
                'description' => array(
                    'title' => __('توضیحات:', 'payline'),
                    'type' => 'textarea',
                    'description' => __('توضیحات قابل نمایش به کاربر در هنگام انتخاب درگاه پرداخت', 'payline'),
                    'default' => __('پرداخت از طریق درگاه Payline با کارت های عضو شتاب', 'payline')),
                'merchant_id' => array(
                    'title' => __('شناسه API درگاه', 'payline'),
                    'type' => 'text',
                    'description' => __('API درگاه را وارد کنید')),
                'vahed' => array(
                    'title' => __('واحد پولی'),
                    'type' => 'select',
                    'options' => array(
                    'rial' => 'ریال',
                    'toman' => 'تومان'
                    ),
                    'description' => "نیازمند افزونه ریال و تومان هست"),
                'redirect_page_id' => array(
                    'title' => __('صفحه بازگشت'),
                    'type' => 'select',
                    'options' => $this -> get_pages('انتخاب برگه'),
                    'description' => "ادرس بازگشت از پرداخت در هنگام پرداخت"
                )
            );


        }

        public function admin_options(){
            echo '<h3>'.__('درگاه پرداخت Payline', 'payline').'</h3>';
            echo '<p>'.__('درگاه پرداخت اینترنتی Payline').'</p>';
            echo '<table class="form-table">';
            $this -> generate_settings_html();
            echo '</table>';

        }


        function payment_fields(){
            if($this -> description) echo wpautop(wptexturize($this -> description));
        }

        function receipt_page($order){
            echo '<p>'.__('با تشکر از سفارش شما. در حال انتقال به درگاه پرداخت...', 'payline').'</p>';
            echo $this -> generate_payline_form($order);
        }

        function process_payment($order_id){
            $order = &new WC_Order($order_id);
            return array('result' => 'success', 'redirect' => $order->get_checkout_payment_url( true )); 
        }

       function check_payline_response(){
            global $woocommerce;
        $order_id = $woocommerce->session->zegersot;
        $order = &new WC_Order($order_id);
        if($order_id != ''){
        if($order -> status !='completed'){
        $url = 'http://payline.ir/payment/gateway-result-second';
        $api=$this -> merchant_id;
        $trans_id = $_POST['trans_id']; 
        $id_get = $_POST['id_get']; 
        $result = $this ->get($url,$api,$trans_id,$id_get); 
        if($result == 1 AND $woocommerce->session->zegersot_id==$id_get)
        {
                                    $this -> msg['message'] = "پرداخت شما با موفقیت انجام شد<br/>کد پیگیری: $trans_id <br/> سلام. این پیغام مدیر هستش... ";
                                    $this -> msg['class'] = 'success';
                                        $order -> payment_complete();
                                        $order -> add_order_note('پرداخت انجام شد<br/>کد پیگیری: '.$trans_id .' AND '.$id_get.'سلام این پیغام دوم مدیر هستش' );
                                        $order -> add_order_note($this->msg['message']);
                                        $woocommerce -> cart -> empty_cart();
        }else
        {
        $this -> msg['class'] = 'error';
        $this -> msg['message'] = "پرداخت با موفقيت انجام نشد";
        }
            }else{
            $this -> msg['class'] = 'error';
        $this -> msg['message'] = "قبلا اين سفارش به ثبت رسيده يا صفارشي موجود نيست!";
            }
            }
                $redirect_url = ($this -> redirect_page_id=="" || $this -> redirect_page_id==0)?get_site_url() . "/":get_permalink($this -> redirect_page_id);
                $redirect_url = add_query_arg( array('msg'=> base64_encode($this -> msg['message']), 'type'=>$this -> msg['class']), $redirect_url );

                wp_redirect( $redirect_url );
                exit;
            }




        function showMessage($content){
            return '<div class="box '.$this -> msg['class'].'-box">'.$this -> msg['message'].'</div>'.$content;
        }


        public function generate_payline_form($order_id){
            global $woocommerce;
            $order = new WC_Order($order_id);
            $redirect_url = ($this -> redirect_page_id=="" || $this -> redirect_page_id==0)?get_site_url() . "/":get_permalink($this -> redirect_page_id);
            $redirect_url = add_query_arg( 'wc-api', get_class( $this ), $redirect_url );
            unset( $woocommerce->session->zegersot );
            unset( $woocommerce->session->zegersot_id );
            $woocommerce->session->zegersot = $order_id;
            $url = 'http://payline.ir/payment/gateway-send'; 
            $api=$this -> merchant_id;
            $amount = $order -> order_total; 
            if($this -> vahed=='toman')
            $amount = $amount*10;
            $redirect = urlencode($redirect_url); 
            $result = $this ->send($url,$api,$amount,$redirect); 
            if($result > 0 && is_numeric($result)){ 
            $woocommerce->session->zegersot_id=$result;
            $go = "http://payline.ir/payment/gateway-$result"; 
            header("Location: $go"); 
            }else if($result=='-1'){
            echo "api ارسالي با نوغ api تعريف شده در payline سازگار نيست";
            }else if($result=='-2'){
            echo "مقدار مبلغ نبايد کمتر از 1000 ريال باشد";
            }else if($result=='-3'){
            echo "error";
            }else if($result=='-4'){
            echo "درگاهي با اطلاعات ارسالي شما يافت نشده و يا در حالت انتظار مي باشد";
            }


        }

private function send($url,$api,$amount,$redirect){ 
    $ch = curl_init(); 
    curl_setopt($ch,CURLOPT_URL,$url); 
    curl_setopt($ch,CURLOPT_POSTFIELDS,"api=$api&amount=$amount&redirect=$redirect"); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 
    $res = curl_exec($ch); 
    curl_close($ch); 
    return $res; 
}
    private function get($url,$api,$trans_id,$id_get){ 
    $ch = curl_init(); 
    curl_setopt($ch,CURLOPT_URL,$url); 
    curl_setopt($ch,CURLOPT_POSTFIELDS,"api=$api&id_get=$id_get&trans_id=$trans_id"); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 
    $res = curl_exec($ch); 
    curl_close($ch); 
    return $res; 
} 
        function get_pages($title = false, $indent = true) {
            $wp_pages = get_pages('sort_column=menu_order');
            $page_list = array();
            if ($title) $page_list[] = $title;
            foreach ($wp_pages as $page) {
                $prefix = '';
                // show indented child pages?
                if ($indent) {
                    $has_parent = $page->post_parent;
                    while($has_parent) {
                        $prefix .=  ' - ';
                        $next_page = get_page($has_parent);
                        $has_parent = $next_page->post_parent;
                    }
                }
                // add to page list array array
                $page_list[$page->ID] = $prefix . $page->post_title;
            }
            return $page_list;
        }

    }


    function woocommerce_add_payline_gateway($methods) {
        $methods[] = 'WC_Payline';
        return $methods;
    }

    add_filter('woocommerce_payment_gateways', 'woocommerce_add_payline_gateway' );
}

?>
این کارو که کردم اخطار داد:

افزونه هنگام فعال شدن٬ 2 نویسه از یک خروجی غیرمنتظره تولید کرد. اگر با پیغام خطای “headers already sent”٬ مشکلات مربوط به خوراک و یا مسائل دیگر مواجه شدید سعی کنید افزونه را غیرفعال یا حذف کنید.

بعدهم به درگاه وصل هم نمیشد!

 

Mohammad

مدیر انجمن
پرسنل مدیریت
با نرم افزار notepad++ کار کنید و به صورت utf8 with out bom ذخیره کنید فایل رو

 

yas_persian

تازه وارد
با نرم افزار notepad++ کار کنید و به صورت utf8 with out bom ذخیره کنید فایل رو
این کارو کردم. اخطار هم نداد. ولی پیام هم نشون نداد. بعد قالب برگه وضعیت پرداخت رو که مشتری بعد از پرداخت میبینه رو هم بهم ریخت.

You must be registered for see images attach


 

Mohammad

مدیر انجمن
پرسنل مدیریت
الان روی یک قالب در لوکال تست کردم. براحتی پاسخ داد

 
بالا