Forum Replies Created

Viewing 15 replies - 1 through 15 (of 21 total)
  • had the same suspicious file in my system. deleted…and guess what it came back. Looking for the culprit now.
    does anybody have an idea how to best track the creation of this file?

    @steve
    encountering the same issue. have you ever resolved this?
    do you know what it was?

    thanks for any help

    Thread Starter fitbox

    (@fitmealat)

    ok removing works great. thanks.

    i was wondering how i would implement custom validation methods analogous to

    add_action( 'woocommerce_checkout_process', 'my_custom_checkout_field_process' );
    	function my_custom_checkout_field_process() {
    
    			if ( ! $_POST['shipping_first_name'] ) {
    				wc_add_notice( 'Bitte gib deinen Vollst?ndingen Namen ein', 'error' );
    			}
    
    		}

    Thread Starter fitbox

    (@fitmealat)

    solved.

    since my class was already initialized with the code above the end part needs to be changed to:

    add_filter( ‘woocommerce_shipping_methods’, ‘register_test_method’ );
    function register_test_method( $methods ) {
    $methods[ ‘test_method’ ] = new WC_Shipping_Bike();
    return $methods;
    }

    final working code as plugin

    <?php
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly
    }
    /*
    Plugin Name: eigenes hipping
    Plugin URI: fitmeal.at
    Description: asdfsfd
    Version: 1.0
    Author: Philipp Protschka
    Author URI: fitmeal.at
    License: GPL
    */
    /**
     * Check if WooCommerce is active
     */
     /**
     * Check if WooCommerce is active
     */
    
    if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    
    	function bike_shipping_method_init() {
    		if ( ! class_exists( 'WC_Shipping_Bike' ) ) {
    		class WC_Shipping_Bike extends WC_Shipping_Method {
    
    	/**
    	 * Constructor. The instance ID is passed to this.
    	 */
    	public function __construct( $instance_id = 0 ) {
    		$this->id                    = 'test_method';
    		$this->instance_id 			     = absint( $instance_id );
    		$this->method_title          = __( 'Test Method' );
    		$this->method_description    = __( 'Some shipping method.' );
    		$this->supports              = array(
    			'shipping-zones',
    			'instance-settings',
    		);
    
    	    	$this->instance_form_fields = array(
            		'enabled' => array(
            			'title' 		=> __( 'Enable/Disable' ),
            			'type' 			=> 'checkbox',
            			'label' 		=> __( 'Enable this shipping method' ),
            			'default' 		=> 'yes',
            		),
            		'title' => array(
            			'title' 		=> __( 'Method Title' ),
            			'type' 			=> 'text',
            			'description' 	=> __( 'This controls the title which the user sees during checkout.' ),
            			'default'		=> __( 'Test Method' ),
            			'desc_tip'		=> true
            		)
    		);
    		$this->enabled		    = $this->get_option( 'enabled' );
    		$this->title                = $this->get_option( 'title' );
    
    		add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) );
    	}
    
    	/**
    	 * calculate_shipping function.
    	 * @param array $package (default: array())
    	 */
    	public function calculate_shipping( $package = array() ) {
    		$this->add_rate( array(
    			'id'    => $this->id . $this->instance_id,
    			'label' => $this->title,
    			'cost'  => 100,
    		) );
    	}
    }
    
    		//class ends here
    		}
    	}
    
    	add_action( 'woocommerce_shipping_init', 'bike_shipping_method_init' );
    
    	add_filter( 'woocommerce_shipping_methods', 'register_test_method' );
    	function register_test_method( $methods ) {
    		$methods[ 'test_method' ] = new WC_Shipping_Bike();
    		return $methods;
    	}
    }
    Thread Starter fitbox

    (@fitmealat)

    even with your code from git i get same errors:
    ERROR
    this is after i select the custom shipping method from the drop down when trying to add it to a zone. It shows up in the dropdown but is not added to the zone.

    perhaps my method of implementation is wrong?

    <?php
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly
    }
    /*
    Plugin Name: eigenes hipping
    Plugin URI: fitmeal.at
    Description: asdfsfd
    Version: 1.0
    Author: Philipp Protschka
    Author URI: fitmeal.at
    License: GPL
    */
    /**
     * Check if WooCommerce is active
     */
     /**
     * Check if WooCommerce is active
     */
    
    if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    
    	function bike_shipping_method_init() {
    		if ( ! class_exists( 'WC_Shipping_Bike' ) ) {
    		class WC_Shipping_Test_Method extends WC_Shipping_Method {
    
    	/**
    	 * Constructor. The instance ID is passed to this.
    	 */
    	public function __construct( $instance_id = 0 ) {
    		$this->id                    = 'test_method';
    		$this->instance_id 			     = absint( $instance_id );
    		$this->method_title          = __( 'Test Method' );
    		$this->method_description    = __( 'Some shipping method.' );
    		$this->supports              = array(
    			'shipping-zones',
    			'instance-settings',
    		);
    
    	    	$this->instance_form_fields = array(
            		'enabled' => array(
            			'title' 		=> __( 'Enable/Disable' ),
            			'type' 			=> 'checkbox',
            			'label' 		=> __( 'Enable this shipping method' ),
            			'default' 		=> 'yes',
            		),
            		'title' => array(
            			'title' 		=> __( 'Method Title' ),
            			'type' 			=> 'text',
            			'description' 	=> __( 'This controls the title which the user sees during checkout.' ),
            			'default'		=> __( 'Test Method' ),
            			'desc_tip'		=> true
            		)
    		);
    		$this->enabled		    = $this->get_option( 'enabled' );
    		$this->title                = $this->get_option( 'title' );
    
    		add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) );
    	}
    
    	/**
    	 * calculate_shipping function.
    	 * @param array $package (default: array())
    	 */
    	public function calculate_shipping( $package = array() ) {
    		$this->add_rate( array(
    			'id'    => $this->id . $this->instance_id,
    			'label' => $this->title,
    			'cost'  => 100,
    		) );
    	}
    }
    
    		//class ends here
    		}
    	}
    
    	add_action( 'woocommerce_shipping_init', 'bike_shipping_method_init' );
    
    	function add_your_shipping_method( $methods ) {
    		$methods[] = 'WC_Shipping_Test_Method';
    		return $methods;
    	}
    
    	add_filter( 'woocommerce_shipping_methods', 'add_your_shipping_method' );
    }
    Thread Starter fitbox

    (@fitmealat)

    mike you are everywhere…! thanks for the pointer will try adapt.

    i think there is an error on line 17 in the example code located here:
    https://gist.github.com/mikejolley/3b37b9cc19a774665f31

    $this->method_title = __( ‘Test Method‘ );

    Parse error: syntax error, unexpected ” ); ‘ (T_CONSTANT_ENCAPSED_STRING)

    kannst gern auf meiner seite freudig testen (is nur ne testing platform)

    naja weil du es ja dort vlt auch mit css versteckt hast? oder fehlt das ganze ding?

    mach lieber: #billing_address_1 {display:none !important;}

    sonst styled das irgend eine theme wieder auf display: float etc. etc…

    are you loading jquery?
    how are you loading this javascript?

    Thread Starter fitbox

    (@fitmealat)

    ideas?

    hab da einfach 4 neue felder erstellt
    strasse/hausnummer/tuernummer/stiege (zb) wenn einer von denen geaaendert wird kopiert es den gesammen text dann in die shipping_adress_1

    //fire copy function everytime a change happens to any of those fields
    jQuery("#shipping_strasse ,#shipping_house_number, #shipping_stiege, #shipping_door_number").on('change', update_shipping_adress);
    
    // copies all values from all these fields to the shipping_adress_1 field
    	function update_shipping_adress () {
    
    	var strasse = jQuery("#shipping_strasse").val();
    	var hausnummer = jQuery("#shipping_house_number").val();
    	var stiegen = jQuery("#shipping_stiege").val();
    	var tuer = jQuery("#shipping_door_number").val();
    	jQuery("#shipping_address_1").val(strasse +' '+ hausnummer +' /'+ stiegen +'/'+ tuer);
    }

    ich würde zwei neue felder anlegen und das originalle “billing adress” verstecken. dann mit einem Javascript das ganze in das versteckte kopieren.

    Sichtbar:
    Strasse
    Hausnummer

    Unsichtbar:
    billing_adress_1

    javascript guckt “onchange” strasse und hausnummer und kopiert es ins billing adress 1. Du kannst dann auch per “custom validation” überprüfen das strasse und hausnummer ausgefüllt wurde.

    google mal “how to create custom woocommerce fields” bzw “woocommerce custom fields validation”

    english
    create 2 new fields “street” and “number”. Hide the original billing_adress_1 field . Create javascript to copy streent and number into billing_adress_1

    use custom validation to check that street and numbers was filled out during submission.

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