Hallo,
ich bin gerade dabei, für unseren Verein eine Möglichkeit zu schaffen, sich online für unsere Ausflüge zu registrieren. Zuvor wurde das alles mit Excellisten realisiert, was gerne zu einem Durcheinander geführt hat. Nun möchte ich alles automatisieren. Anmeldung, Anzahlung und Bettvergabe. Die Touren gehen über das Wochenende und daher ist von den Mitgliedern eine Anzahlung für die Übernachtung fällig. Dies hatten wir bis jetzt immer über PayPal senden an einen Freund an unser Vereinskonto gemacht.
Ich habe nun Wordpress auf einem Server am Laufen. Als "Produkte" habe ich die Zimmer (EZ, DZ,...) erstellt. Der Preis ist dabei die Anzahlung. Mit dem Lagerbestand stelle sicher, dass ein Zimmer nicht überbucht werden kann. Eines der Vorteile von WP. Die Seite hat also keinerlei kommerziellen Hintergrund.
Mein Problem ist, dass ich kein Plugin finde, mit dem ich die Zahlung an Freunde realisieren kann. Auch funktioniert mein selbst zusammengebasteltes Plugin nicht. Wer hat eine Idee?
[PLAIN]
<?php
defined( 'ABSPATH' );
/**
* Plugin Name: WooCommerce PayPal Send to Friend
* Description: This plugin allows you to send a PayPal payment to a friend.
* Version: 0.0.8
* Author: Marcus
*/
add_action( 'plugins_loaded', function() {
// Register the new payment gateway.
add_action( 'woocommerce_payment_gateways', function() {
register_woocommerce_payment_gateway( new WC_Gateway_PayPal_Send_To_Friend() );
});
// Add the settings page.
add_action( 'admin_menu', function() {
add_submenu_page(
'woocommerce',
'PayPal Send to Friend',
'PayPal Send to Friend',
'manage_options',
'wc-settings-paypal-send-to-friend',
function() {
include 'views/settings-page.php';
}
);
});
});
/**
* Class WC_Gateway_PayPal_Send_To_Friend
*
* Represents the PayPal Send to Friend payment gateway.
*/
class WC_Gateway_PayPal_Send_To_Friend extends WC_Payment_Gateway {
/**
* Constructor.
*/
public function __construct() {
$this->id = 'paypal_send_to_friend';
$this->method_title = __( 'PayPal Send to Friend', 'woocommerce' );
$this->method_description = __( 'Allows you to send a PayPal payment to a friend.', 'woocommerce' );
$this->supports = array(
'products',
'subscriptions',
'recurring_payments',
);
}
/**
* Get the payment gateway settings.
*
* @return array
*/
public function get_settings() {
return array(
'enabled' => array(
'title' => __( 'Enable', 'woocommerce' ),
'type' => 'checkbox',
),
'title' => array(
'title' => __( 'Title', 'woocommerce' ),
'type' => 'text',
'default' => __( 'PayPal Send to Friend', 'woocommerce' ),
),
'description' => array(
'title' => __( 'Description', 'woocommerce' ),
'type' => 'textarea',
'default' => __( 'Send a PayPal payment to a friend.', 'woocommerce' ),
),
);
}
/**
* Process the payment.
*
* Param WC_Order $order
* @return WC_Payment_Gateway_Result
*/
public function process_payment( $order_id ) {
$order = wc_get_order( $order_id );
$redirect_url = add_query_arg(
array(
'wc_order' => $order->get_id(),
),
wc_get_checkout_url()
);
return new WC_Payment_Gateway_Result(
array(
'result' => 'success',
'redirect' => $redirect_url,
)
);
}
}
[/PLAIN]
[PLAIN]
<div class="wrap">
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
<?php
settings_fields( 'paypal_send_to_friend_settings' );
do_settings_sections( 'paypal_send_to_friend_settings' );
?>
<form method="post" action="options.php">
<table class="form-table">
<tr>
<th scope="row"><label for="friend_email"><?php _e( 'Freund E-Mail', 'woocommerce' ); ?></label></th>
<td>
<input type="email" name="friend_email" id="friend_email" value="<?php echo esc_attr( get_option( 'friend_email', '' ) ); ?>" class="regular-text" required />
</td>
</tr>
<tr>
<th scope="row"><label for="payment_amount"><?php _e( 'Zahlungsbetrag', 'woocommerce' ); ?></label></th>
<td>
<input type="number" name="payment_amount" id="payment_amount" value="<?php echo esc_attr( get_option( 'payment_amount', '' ) ); ?>" step="0.01" min="0" required />
</td>
</tr>
</table>
<?php
submit_button();
?>
</form>
</div>
[/PLAIN]
Danke schon einmal für eure Ideen und Ratschläge