Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public_html/wp-content/plugins/user-switching/
public_html/wp-content/plugins/akismet
public_html/wp-content/plugins/bbpress
public_html/wp-content/plugins/buddypress
public_html/wp-content/plugins/camptix-bd-payments/
public_html/wp-content/plugins/camptix-kdcpay-gateway
public_html/wp-content/plugins/camptix-mercadopago
public_html/wp-content/plugins/camptix-network-tools
Expand Down
11 changes: 0 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@
"reference": "branches/2.6/"
}
},
{
"name": "wordpress-plugin/camptix-bd-payments",
"type": "wordpress-plugin",
"version": "1.2",
"source": {
"type": "svn",
"url": "https://plugins.svn.wordpress.org/bd-payments-camptix/",
"reference": "tags/1.2/"
}
},
{
"name": "wordpress-plugin/camptix-mercadopago",
"type": "wordpress-plugin",
Expand Down Expand Up @@ -126,7 +116,6 @@
"composer/installers": "^2.2",
"wpackagist-plugin/akismet": "*",
"wordpress-plugin/bbpress": "2.6.*",
"wordpress-plugin/camptix-bd-payments": "1.2",
"wordpress-plugin/camptix-mercadopago": "1.0.6",
"wpackagist-plugin/camptix-pagseguro": "*",
"wpackagist-plugin/camptix-payfast-gateway": "*",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
/**
* Plugin Name: Camptix BD Payments
* Description: Bangladeshi payment gateways for CampTix
* Plugin URI: https://github.com/tareq1988/camptix-bd-payments
* Author: Tareq Hasan
* Author URI: https://tareq.co
* Version: 1.3
* License: GPL2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: bd-payments-camptix
*/

defined( 'ABSPATH' ) || exit;

/**
* Main Class
*/
class CampTix_BD_Gateways {

/**
* [__construct description]
*/
function __construct() {
add_action( 'plugins_loaded', [ $this, 'init_plugin' ] );
add_action( 'camptix_load_addons', [ $this, 'load_addons'] );
add_filter( 'camptix_currencies', [ $this, 'add_currency' ] );
}

/**
* Initialize the plugin
*
* @return void
*/
public function init_plugin() {
$this->includes();
}

/**
* Include files
*
* @return void
*/
public function includes() {

if ( ! class_exists( 'CampTix_Payment_Method' ) ) {
return;
}

require_once __DIR__ . '/includes/class-phone-field.php';
require_once __DIR__ . '/includes/gateway/class-gateway-sslcommerz.php';
}

/**
* Load the add-ons
*
* @return void
*/
public function load_addons() {
camptix_register_addon( '\CamptixBD\Gateway\SSLCommerz' );
camptix_register_addon( '\CamptixBD\Phone_Field' );
}

/**
* Add BDT currency
*
* @param array $currencies
*
* @return array
*/
public function add_currency( $currencies ) {
$currencies['BDT'] = [
'label' => __( 'Taka', 'bd-payments-camptix' ),
'format' => 'BDT %s',
'decimal_point' => 2,
];

return $currencies;
}
}

new CampTix_BD_Gateways();
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<?php
namespace CamptixBD;

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

class Phone_Field {

/**
* Constructor
*/
public function __construct() {
$this->setup_hooks();
}

/**
* Setup hooks
*/
private function setup_hooks() {
// Add, save and show extra fields.
add_action( 'camptix_attendee_form_additional_info', array( $this, 'add_fields' ), 10, 3 );
add_filter( 'camptix_form_register_complete_attendee_object', array( $this, 'add_attendee_info' ), 10, 3 );
add_action( 'camptix_checkout_update_post_meta', array( $this, 'save_attendee_info' ), 10, 2 );
add_filter( 'camptix_metabox_attendee_info_additional_rows', array( $this, 'show_attendee_info' ), 10, 2 );
add_filter( 'camptix_form_edit_attendee_additional_info', array( $this, 'add_fields_edit_attendee_info', ), 10, 1 );
add_filter( 'camptix_form_edit_attendee_update_post_meta', array( $this, 'save_edited_attendee_info' ), 10, 2 );
add_filter( 'camptix_form_edit_attendee_custom_error_flags', array( $this, 'edit_attendee_info_Form_error', ), 10, 1 );
add_filter( 'camptix_attendee_report_extra_columns', array( $this, 'export_attendee_data_column' ), 10, 1 );
add_filter( 'camptix_attendee_report_column_value', array( $this, 'export_attendee_data_value' ), 10, 3 );
}

/**
* Add phone field
*
* @param $form_data
* @param $current_count
* @param $tickets_selected_count
*
* @return string
*/
public function add_fields( $form_data, $current_count, $tickets_selected_count ) {
?>
<tr class="tix-row-phone">
<td class="tix-required tix-left">
<?php esc_html_e( 'Phone Number', 'bd-payments-camptix' ); ?>
<span class="tix-required-star">*</span>
</td>
<?php $value = isset( $form_data['tix_attendee_info'][ $current_count ]['phone'] ) ? $form_data['tix_attendee_info'][ $current_count ]['phone'] : ''; ?>
<td class="tix-right">
<input name="tix_attendee_info[<?php echo esc_attr( $current_count ); ?>][phone]" type="text" class="mobile" value="<?php echo esc_attr( $value ); ?>"/><br>
<small class="message"></small>
</td>
</tr>
<?php
}


/**
* Add extra attendee information
*
* @param $attendee
* @param $attendee_info
* @param $current_count
*
* @return mixed
*/
public function add_attendee_info( $attendee, $attendee_info, $current_count ) {
// Phone.
if ( ! empty( $_POST['tix_attendee_info'][ $current_count ]['phone'] ) ) {
$attendee->phone = trim( $_POST['tix_attendee_info'][ $current_count ]['phone'] );
}

return $attendee;
}


/**
* Save extra attendee information
*
* @param $attendee_id
* @param $attendee
*/
public function save_attendee_info( $attendee_id, $attendee ) {
// Phone.
if ( property_exists( $attendee, 'phone' ) ) {
update_post_meta( $attendee_id, 'tix_phone', $attendee->phone );
}
}

/**
* Show extra attendee information
*
* @param $rows
* @param $attendee
*
* @return array
*/
public function show_attendee_info( $rows, $attendee ) {
// Phone.
if ( $attendee_phone = get_post_meta( $attendee->ID, 'tix_phone', true ) ) {
$rows[] = array(
__( 'Phone Number', 'bd-payments-camptix' ),
$attendee_phone,
);
}

return $rows;
}

/**
* Show extra attendee information
*
* @since 1.0
* access public
*
* @param $attendee
*
* @return array
*/
public function add_fields_edit_attendee_info( $attendee ) {
?>
<tr>
<td class="tix-required tix-left">
<?php esc_html_e( 'Phone Number', 'bd-payments-camptix' ); ?>
<span class="tix-required-star">*</span>
</td>
<td class="tix-right">
<input name="tix_ticket_info[phone]" type="text" value="<?php echo esc_attr( get_post_meta( $attendee->ID, 'tix_phone', true ) ); ?>"/>
</td>
</tr>
<?php
}


/**
* Set custom error for edit attendee information form
*
* @since 1.0
* access public
*
* @param $attendee
*
* @return array
*/
public function edit_attendee_info_Form_error( $attendee ) {
/* @var CampTix_Plugin $camptix */
global $camptix;

// Phone.
if ( isset( $_POST['tix_attendee_save'] ) ) {
if ( empty( $_POST['tix_ticket_info']['phone'] ) ) {
// $camptix->error( __( 'Please fill in all required fields.', 'camptix-indian-payments' ) );
$_POST['tix_ticket_info']['phone'] = get_post_meta( $attendee->ID, 'tix_phone', true );
}
}
}


/**
* Save edited attendee information
*
* @param $new_ticket_info
* @param $attendee
*
* @return array
*/
public function save_edited_attendee_info( $new_ticket_info, $attendee ) {
// Phone.
if ( array_key_exists( 'phone', $new_ticket_info ) ) {
update_post_meta( $attendee->ID, 'tix_phone', sanitize_text_field( $new_ticket_info['phone'] ) );
}
}


/**
* Add column to export extra attendee information
*
* @param array $extra_columns
*
* @return array
*/
public function export_attendee_data_column( $extra_columns ) {
return array(
'phone' => __( 'Phone Number', 'bd-payments-camptix' ),
);
}

/**
* Add column to export extra attendee information
*
* @param $value
* @param $column_name
* @param $attendee
*
* @return mixed
*/
public function export_attendee_data_value( $value, $column_name, $attendee ) {
switch ( $column_name ) {
case 'phone':
$value = get_post_meta( $attendee->ID, 'tix_phone', true );
break;
}

return $value;
}
}
Loading
Loading