Skip to content

Commit

Permalink
Merge pull request #159 from culqi/feature/order_status_setting
Browse files Browse the repository at this point in the history
Feature/order status setting
  • Loading branch information
JoseHCalderon authored Jun 16, 2023
2 parents 7b84351 + 62abe4c commit c925621
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 5 deletions.
16 changes: 16 additions & 0 deletions admin/class-fullculqi-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ public function register_settings() {
'fullculqi_section' // Section
);

add_settings_field(
'fullculqi_estado_pedido', // ID
esc_html__( 'Estado final del pedido', 'fullculqi' ) , // Estado complete
[ $this, 'input_estado_pedido' ], // Callback
'fullculqi_page', // Page
'fullculqi_section', // Section
);

do_action('fullculqi/settings/sync_fields', $settings, $this);

add_settings_field(
Expand Down Expand Up @@ -285,5 +293,13 @@ public function input_delete_all() {
</label>';
}

public function input_estado_pedido() {
$settings = fullculqi_get_settings();

echo '<label for="fullculqi_estado_pedido">
<input type="text" id="fullculqi_estado_pedido" class="regular-text" name="fullculqi_options[estado_pedido]" value="'.$settings['estado_pedido'].'"/>
</label>';
}

}
?>
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function actions() {
* @return mixed
*/
public function update_order( $culqi_order ) {

$settings = fullculqi_get_settings();
if( ! isset( $culqi_order->id ) )
return;

Expand Down Expand Up @@ -143,7 +143,7 @@ public function update_order( $culqi_order ) {

// Status

$order->update_status( 'processing',
$order->update_status( $settings['estado_pedido'],
sprintf(
esc_html__( 'Estado cambiado (a %s)', 'fullculqi' ),
$method['status_success']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static function order( $post_data = [] ) {
* @return bool
*/
public static function charge( $post_data = [] ) {

$settings = fullculqi_get_settings();
// Settings WC
$method = get_option( 'woocommerce_fullculqi_settings' );

Expand Down Expand Up @@ -414,8 +414,18 @@ public static function charge( $post_data = [] ) {
),
], $order );

// Change Status
// Change Status to processing
$order->update_status( $status['name'], $status['note'] );

// Change Status to completed
if ($settings['estado_pedido']=="completed"){
$order->update_status( $settings['estado_pedido'],
sprintf(
esc_html__( 'Estado cambiado (a %s)', 'fullculqi' ),
$method['status_success']
)
);
}
}

do_action( 'fullculqi/process/charge_success', $order );
Expand Down
14 changes: 14 additions & 0 deletions includes/admin/class-fullculqi-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,15 @@ public function register_settings() {
array( 'class' => 'fullculqi_password' )
);

add_settings_field(
'fullculqi_estado_pedido', // ID
esc_html__( 'Estado final del pedido', 'fullculqi' ) , // Estado complete
[ $this, 'input_estado_pedido' ], // Callback
'fullculqi_page', // Page
'fullculqi_section', // Section
array( 'class' => 'fullculqi_estado_pedido' )
);

add_settings_field(
'fullculqi_buttoncustom', // ID
esc_html__( 'Personalizar formulario de checkout', 'fullculqi' ), // Logo
Expand Down Expand Up @@ -474,6 +483,11 @@ public function input_password() {
fullculqi_get_template( 'resources/layouts/admin/settings/input_password.php', $settings );
}

public function input_estado_pedido() {
$settings = fullculqi_get_settings();

fullculqi_get_template( 'resources/layouts/admin/settings/input_estado_pedido.php', $settings );
}
/**
* Input URL logo
* @return html
Expand Down
3 changes: 2 additions & 1 deletion includes/class-fullculqi-wc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php/*
class FullCulqi_WC {
public function __construct() {
Expand Down Expand Up @@ -168,4 +168,5 @@ public function update_order() {
die();
}
}
*/
?>
1 change: 1 addition & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function fullculqi_get_default() {
'notify_pay' => '',
'username' => '',
'password' => '',
'estado_pedido' => '',
'color_palette' => ''
];

Expand Down
6 changes: 6 additions & 0 deletions resources/layouts/admin/settings/input_estado_pedido.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<label for="fullculqi_estado_pedido">
<select id="fullculqi_estado_pedido" class="regular-text" name="fullculqi_options[estado_pedido]">
<option value="processing" <?php if(esc_html($estado_pedido) == 'processing'): ?> selected="selected"<?php endif; ?>>Processing</option>
<option value="completed" <?php if(esc_html($estado_pedido) == 'completed'): ?> selected="selected"<?php endif; ?>>Completed</option>
</select>
</label>

0 comments on commit c925621

Please sign in to comment.