Visualizzazione risultati 1 fino 9 di 9

Discussione: chi mi aiuta ? unexpected T_VARIABLE

  1. #1
    Guest

    Exclamation chi mi aiuta ? unexpected T_VARIABLE

    Ragazzi stò modificando un plugin per l'aggiunta del pagamento tramite Postpay a WooCommerce, stò aggiungedo una nuova funzione cioè l'aggiunta del "Intestatario Carta" non presente ufficialmente nel plugin...
    Quando lo vado ad uplodare mi dà questo errore :
    Parse error: syntax error, unexpected T_VARIABLE, expecting ')' in /membri/ingrossosmokenatural/blog/wp-content/plugins/prova/giovannialbero_prova.php on line 117

    Codice PHP:
    <?php
    /*
    Plugin Name: Postepay Getaway per Woocommerce
    Plugin URI: http://plugins.svn.wordpress.org/postepay-woocommerce-gateway/
    Description: Permette la scelta di Postepay come metodo di pagamento, fornendo il mumero di carta al momento del checkout.
    Version: 0.1
    Author: Martino Stenta
    Author URI: http://www.noiza.com
    License: GPL2
    */
    add_action('plugins_loaded', 'woocommerce_ppay_init', 0);

    function
    woocommerce_ppay_init() {

    class
    WC_PPAY extends WC_Payment_Gateway {

    public function
    __construct() {
    $this->id = 'ppay';
    $this->icon = apply_filters('woocommerce_bacs_icon', '');
    $this->has_fields = false;
    $this->method_title = __( 'Ppay', 'woocommerce' );
    // Load the form fields.
    $this->init_form_fields();

    // Load the settings.
    $this->init_settings();

    // Define user set variables
    $this->title = $this->settings['title'];
    $this->description = $this->settings['description'];
    $this->ppay_number = $this->settings['ppay_number'];
    $this->ppay_user = $this->settings['ppay_user'];

    // Actions
    add_action('woocommerce_update_options_payment_gateways', array(&$this, 'process_admin_options'));
    add_action('woocommerce_thankyou_ppay', array(&$this, 'thankyou_page'));

    // Customer Emails
    add_action('woocommerce_email_before_order_table', array(&$this, 'email_instructions'), 10, 2);
    }

    /**
    * Initialise Gateway Settings Form Fields
    */
    function init_form_fields() {

    $this->form_fields = array(
    'enabled' => array(
    'title' => __( 'Abilita/Disabilita', 'woocommerce' ),
    'type' => 'checkbox',
    'label' => __( 'Abilita Postepay', 'woocommerce' ),
    'default' => 'yes'
    ),
    'title' => array(
    'title' => __( 'Titolo', 'woocommerce' ),
    'type' => 'text',
    'description' => __( 'Definisci il titolo del sistema di pagamento.', 'woocommerce' ),
    'default' => __( 'Postepay', 'woocommerce' )
    ),
    'description' => array(
    'title' => __( 'Messaggio personalizzato', 'woocommerce' ),
    'type' => 'textarea',
    'description' => __( 'Spiega al cliente come procedere con la ricarica Postepay. Segnala che la merce non sarà inviata fino al ricevimento della ricarica.', 'woocommerce' ),
    'default' => __('Paga con una ricarica Postepay. Mandaci una mail appena hai fatto il versamento indicando il numero d\'ordine e provvederemo all\'invio della merce.', 'woocommerce')
    ),
    'ppay_number' => array(
    'title' => __( 'Numero Postepay', 'woocommerce' ),
    'type' => 'text',
    'description' => '',
    'default' => ''
    ),
    'ppay_user' => array(
    'title' => __( 'Intestatario Carta', 'woocommerce' ),
    'type' => 'text',
    'description' => '',
    'default' => ''
    ),

    );

    }
    // End init_form_fields()

    /**
    * Admin Panel Options
    * - Options for bits like 'title' and availability on a country-by-country basis
    *
    * @since 1.0.0
    */
    public function admin_options() {
    ?>
    <h3><?php _e('Postepay', 'woocommerce'); ?></h3>
    <p><?php _e('Permetti pagamenti attraverso Postepay', 'woocommerce'); ?></p>
    <table class="form-table">
    <?php
    // Generate the HTML For the settings form.
    $this->generate_settings_html();
    ?>
    </table><!--/.form-table-->
    <?php
    } // End admin_options()


    /**
    * There are no payment fields for bacs, but we want to show the description if set.
    **/
    function payment_fields() {
    if (
    $this->description) echo wpautop(wptexturize($this->description));
    }

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

    ?><h2><?php _e('Our Details', 'woocommerce') ?></h2><ul class="order_details ppay_details"><?php

    $fields
    = array(
    'ppay_number'=> __('Numero Postepay', 'woocommerce')
    $fields = array(
    'ppay_user'=> __('Intestatario Carta', 'woocommerce')

    );

    foreach (
    $fields as $key=>$value) :
    if(!empty(
    $this->$key)) :
    echo
    '<li class="'.$key.'">'.$value.': <strong>'.wptexturize($this->$key).'</strong></li>';
    endif;
    endforeach;

    ?></ul><?php
    }

    /**
    * Add text to user email
    **/
    function email_instructions( $order, $sent_to_admin ) {

    if (
    $sent_to_admin ) return;

    if (
    $order->status !== 'on-hold') return;

    if (
    $order->payment_method !== 'ppay') return;

    if (
    $this->description) echo wpautop(wptexturize($this->description));

    ?><h2><?php _e('Informazioni', 'woocommerce') ?></h2><ul class="order_details ppay_details"><?php

    $fields
    = array(
    'ppay_number'=> __('Numero Postepay', '')
    );

    $fields = array(
    'ppay_user'=> __('Intestatario Carta', '')
    );

    foreach (
    $fields as $key=>$value) :
    if(!empty(
    $this->$key)) :
    echo
    '<li class="'.$key.'">'.$value.': <strong>'.wptexturize($this->$key).'</strong></li>';
    endif;
    endforeach;

    ?></ul><?php
    }

    /**
    * Process the payment and return the result
    **/
    function process_payment( $order_id ) {
    global
    $woocommerce;

    $order = new WC_Order( $order_id );

    // Mark as on-hold (we're awaiting the payment)
    $order->update_status('on-hold', __('In attesa di versamento Postepay', 'woocommerce'));

    // Reduce stock levels
    $order->reduce_order_stock();

    // Remove cart
    $woocommerce->cart->empty_cart();

    // Empty awaiting payment session
    unset($_SESSION['order_awaiting_payment']);

    // Return thankyou redirect
    return array(
    'result' => 'success',
    'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('thanks'))))
    );
    }

    }

    /**
    * Add the Gateway to WooCommerce
    **/
    function woocommerce_add_ppay_gateway($methods) {
    $methods[] = 'WC_PPAY';
    return
    $methods;
    }

    add_filter('woocommerce_payment_gateways', 'woocommerce_add_ppay_gateway' );
    }
    Ultima modifica di darkwolf : 27-02-2013 alle ore 01.09.49 Motivo: code @ php

  2. #2
    L'avatar di dreadnaut
    dreadnaut non è connesso Super Moderatore
    Data registrazione
    22-02-2004
    Messaggi
    6,269

    Predefinito

    Attorno alla riga 117 ti sei mangiato dei pezzi. Nella funzione successiva hai scritto le cose correttamente, vedi li.

  3. #3
    Guest

    Predefinito

    non riesco a farlo funzionare, cortesemente puoi essere più preciso... grazie mille gentilissimo

  4. #4
    L'avatar di darkwolf
    darkwolf non è connesso Super Moderatore
    Data registrazione
    18-04-2007
    Residenza
    Reggiolo (RE)
    Messaggi
    6,552

    Predefinito

    Prova a cambiare quel blocco (intorno alla 117) così:
    Codice PHP:
    $fields = array(
    'ppay_number'=> __('Numero Postepay', 'woocommerce')

    );
    $fields = array(
    'ppay_user'=> __('Intestatario Carta', 'woocommerce')

    );
    Praticamente, da ciò che vedo, semplicemente non hai chiuso il primo array
    » Salvatore Noschese - L'AltroWeb | Seguimi su: facebook | twitter | Google+
    # Che aspetti? Unisciti alla community! Tanti nuovi gruppi ti aspettano


  5. #5
    Guest

    Predefinito

    Gia ci avevo provato... ma quando vado ad effettuare l'ordine e come pagamento scelgo Postpay poi nella pagina "thank_you" dove deve dare le due informazioni di cui parliamo

    ppay_numer (numero carta)
    ppay_user (intestatario carta)

    fa visualizzare solo il secondo ...


  6. #6
    L'avatar di dreadnaut
    dreadnaut non è connesso Super Moderatore
    Data registrazione
    22-02-2004
    Messaggi
    6,269

    Predefinito

    Ma i due array sono lo stesso array, quindi stai sovrascrivendo il primo campo con il primo. Devi aggiungerli entrambi:
    Codice PHP:
    $fields = array(
    'ppay_number'=> __('Numero Postepay', 'woocommerce'),
    'ppay_user'=> __('Intestatario Carta', 'woocommerce')
    );
    Stessa cosa qualche riga più sotto, direi.

  7. #7
    Guest

    Predefinito

    GRAZIE MILLE ! GENTILISSIMO !

    magari a qualcuno serve questo plugin "modificato" mi mandi un pm gli serve ;)

  8. #8
    Guest

    Predefinito

    Ciao, ho un problema... praticamente il plugin non mi salva il numero della carta postepay... ho provato a ricopiare il codice postato qui, corretto con i dati dell'intestatario... ma niente. Com'è possibile? Grazie!

  9. #9
    L'avatar di dreadnaut
    dreadnaut non è connesso Super Moderatore
    Data registrazione
    22-02-2004
    Messaggi
    6,269

    Predefinito

    Come scritto sopra, se ti serve l'intero plugin modificato puoi mandare un messaggio privato a naturalsmoke.

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •