Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: shipping tax fee recipient setting added in admin setup wizard #1980

Merged
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
45 changes: 24 additions & 21 deletions includes/Admin/SetupWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
add_filter( 'user_has_cap', [ $this, 'set_user_cap' ] );
}

if ( current_user_can( 'manage_woocommerce' ) ) {

Check warning on line 33 in includes/Admin/SetupWizard.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found unknown capability "manage_woocommerce" in function call to current_user_can(). Please check the spelling of the capability. If this is a custom capability, please verify the capability is registered with WordPress via a call to WP_Role(s)->add_cap(). Custom capabilities can be made known to this sniff by setting the "custom_capabilities" property in the PHPCS ruleset.
add_action( 'admin_menu', [ $this, 'admin_menus' ] );
add_action( 'admin_init', [ $this, 'setup_wizard' ], 99 );

Expand Down Expand Up @@ -129,7 +129,7 @@
* Add admin menus/screens.
*/
public function admin_menus() {
add_submenu_page( '', '', '', 'manage_woocommerce', 'dokan-setup', '' );

Check warning on line 132 in includes/Admin/SetupWizard.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found unknown capability "manage_woocommerce" in function call to add_submenu_page(). Please check the spelling of the capability. If this is a custom capability, please verify the capability is registered with WordPress via a call to WP_Role(s)->add_cap(). Custom capabilities can be made known to this sniff by setting the "custom_capabilities" property in the PHPCS ruleset.
}

/**
Expand Down Expand Up @@ -204,7 +204,7 @@
* Show the setup wizard.
*/
public function setup_wizard() {
if ( ! current_user_can( 'manage_woocommerce' ) ) {

Check warning on line 207 in includes/Admin/SetupWizard.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found unknown capability "manage_woocommerce" in function call to current_user_can(). Please check the spelling of the capability. If this is a custom capability, please verify the capability is registered with WordPress via a call to WP_Role(s)->add_cap(). Custom capabilities can be made known to this sniff by setting the "custom_capabilities" property in the PHPCS ruleset.
return;
}

Expand Down Expand Up @@ -350,12 +350,13 @@
$general_options = get_option( 'dokan_general', [] );
$custom_store_url = ! empty( $general_options['custom_store_url'] ) ? $general_options['custom_store_url'] : 'store';

$selling_options = get_option( 'dokan_selling', [] );
$shipping_fee_recipient = ! empty( $selling_options['shipping_fee_recipient'] ) ? $selling_options['shipping_fee_recipient'] : 'seller';
$tax_fee_recipient = ! empty( $selling_options['tax_fee_recipient'] ) ? $selling_options['tax_fee_recipient'] : 'seller';
$map_api_source = dokan_get_option( 'map_api_source', 'dokan_appearance', 'google_maps' );
$gmap_api_key = dokan_get_option( 'gmap_api_key', 'dokan_appearance', '' );
$mapbox_access_token = dokan_get_option( 'mapbox_access_token', 'dokan_appearance', '' );
$selling_options = get_option( 'dokan_selling', [] );
$shipping_fee_recipient = ! empty( $selling_options['shipping_fee_recipient'] ) ? $selling_options['shipping_fee_recipient'] : 'seller';
$tax_fee_recipient = ! empty( $selling_options['tax_fee_recipient'] ) ? $selling_options['tax_fee_recipient'] : 'seller';
$shipping_tax_fee_recipient = ! empty( $selling_options['shipping_tax_fee_recipient'] ) ? $selling_options['shipping_tax_fee_recipient'] : 'seller';
$map_api_source = dokan_get_option( 'map_api_source', 'dokan_appearance', 'google_maps' );
$gmap_api_key = dokan_get_option( 'gmap_api_key', 'dokan_appearance', '' );
$mapbox_access_token = dokan_get_option( 'mapbox_access_token', 'dokan_appearance', '' );

$recipients = [
'seller' => __( 'Vendor', 'dokan-lite' ),
Expand All @@ -364,18 +365,19 @@

$args = apply_filters(
'dokan_admin_setup_wizard_step_setup_store_template_args', [
'custom_store_url' => $custom_store_url,
'recipients' => $recipients,
'shipping_fee_recipient' => $shipping_fee_recipient,
'tax_fee_recipient' => $tax_fee_recipient,
'map_api_source' => $map_api_source,
'gmap_api_key' => $gmap_api_key,
'mapbox_access_token' => $mapbox_access_token,
'map_api_source_options' => [
'custom_store_url' => $custom_store_url,
'recipients' => $recipients,
'shipping_fee_recipient' => $shipping_fee_recipient,
'tax_fee_recipient' => $tax_fee_recipient,
'shipping_tax_fee_recipient' => $shipping_tax_fee_recipient,
'map_api_source' => $map_api_source,
'gmap_api_key' => $gmap_api_key,
'mapbox_access_token' => $mapbox_access_token,
'map_api_source_options' => [
'google_maps' => __( 'Google Maps', 'dokan-lite' ),
'mapbox' => __( 'Mapbox', 'dokan-lite' ),
],
'setup_wizard' => $this,
'setup_wizard' => $this,
]
);

Expand All @@ -392,12 +394,13 @@
$selling_options = get_option( 'dokan_selling', [] );
$appearance = get_option( 'dokan_appearance', [] );

$general_options['custom_store_url'] = ! empty( $_POST['custom_store_url'] ) ? sanitize_text_field( wp_unslash( $_POST['custom_store_url'] ) ) : '';
$selling_options['shipping_fee_recipient'] = ! empty( $_POST['shipping_fee_recipient'] ) ? sanitize_text_field( wp_unslash( $_POST['shipping_fee_recipient'] ) ) : '';
$selling_options['tax_fee_recipient'] = ! empty( $_POST['tax_fee_recipient'] ) ? sanitize_text_field( wp_unslash( $_POST['tax_fee_recipient'] ) ) : '';
$appearance['map_api_source'] = ! empty( $_POST['map_api_source'] ) ? sanitize_text_field( wp_unslash( $_POST['map_api_source'] ) ) : '';
$appearance['gmap_api_key'] = ! empty( $_POST['gmap_api_key'] ) ? sanitize_text_field( wp_unslash( $_POST['gmap_api_key'] ) ) : '';
$appearance['mapbox_access_token'] = ! empty( $_POST['mapbox_access_token'] ) ? sanitize_text_field( wp_unslash( $_POST['mapbox_access_token'] ) ) : '';
$general_options['custom_store_url'] = ! empty( $_POST['custom_store_url'] ) ? sanitize_text_field( wp_unslash( $_POST['custom_store_url'] ) ) : '';
$selling_options['shipping_fee_recipient'] = ! empty( $_POST['shipping_fee_recipient'] ) ? sanitize_text_field( wp_unslash( $_POST['shipping_fee_recipient'] ) ) : '';
$selling_options['tax_fee_recipient'] = ! empty( $_POST['tax_fee_recipient'] ) ? sanitize_text_field( wp_unslash( $_POST['tax_fee_recipient'] ) ) : '';
$selling_options['shipping_tax_fee_recipient'] = ! empty( $_POST['shipping_tax_fee_recipient'] ) ? sanitize_text_field( wp_unslash( $_POST['shipping_tax_fee_recipient'] ) ) : '';
$appearance['map_api_source'] = ! empty( $_POST['map_api_source'] ) ? sanitize_text_field( wp_unslash( $_POST['map_api_source'] ) ) : '';
$appearance['gmap_api_key'] = ! empty( $_POST['gmap_api_key'] ) ? sanitize_text_field( wp_unslash( $_POST['gmap_api_key'] ) ) : '';
$appearance['mapbox_access_token'] = ! empty( $_POST['mapbox_access_token'] ) ? sanitize_text_field( wp_unslash( $_POST['mapbox_access_token'] ) ) : '';

$share_essentials = isset( $_POST['share_essentials'] );

Expand Down
19 changes: 17 additions & 2 deletions templates/admin-setup-wizard/step-store.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</td>
</tr>
<tr>
<th scope="row"><label for="tax_fee_recipient"><?php esc_html_e( 'Tax Fee Recipient', 'dokan-lite' ); ?></label></th>
<th scope="row"><label for="tax_fee_recipient"><?php esc_html_e( 'Product Tax Fee Recipient', 'dokan-lite' ); ?></label></th>
<td>
<select class="wc-enhanced-select" id="tax_fee_recipient" name="tax_fee_recipient">
<?php foreach ( $recipients as $key => $value ) : ?>
Expand All @@ -33,7 +33,22 @@
</option>
<?php endforeach; ?>
</select>
<p class="description"><?php esc_html_e( 'Tax fees will go to', 'dokan-lite' ); ?></p>
<p class="description"><?php esc_html_e( 'Product Tax fees will go to', 'dokan-lite' ); ?></p>
</td>
</tr>
<tr>
<th scope='row'><label
for='tax_fee_recipient'><?php esc_html_e( 'Shipping Tax Fee Recipient', 'dokan-lite' ); ?></label>
</th>
<td>
<select class="wc-enhanced-select" id="shipping_tax_fee_recipient" name="shipping_tax_fee_recipient">
<?php foreach ( $recipients as $key => $value ) : ?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $shipping_tax_fee_recipient ); ?>>
<?php echo esc_html( $value ); ?>
</option>
<?php endforeach; ?>
</select>
<p class="description"><?php esc_html_e( 'Shipping Tax fees will go to', 'dokan-lite' ); ?></p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -71,7 +86,7 @@
<input type="text" id="mapbox_access_token" name="mapbox_access_token" class="location-input" value="<?php echo esc_attr( $mapbox_access_token ); ?>" />
<p class="description">
<?php
echo sprintf(

Check failure on line 89 in templates/admin-setup-wizard/step-store.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Unnecessary "echo sprintf(...)" found. Use "printf(...)" instead.
/* translators: %1$s: opening anchor tag, %2$s: closing anchor tag */
esc_html__( '%1$sAccess Token%2$s is needed to display map on store page', 'dokan-lite' ),
'<a href="https://docs.mapbox.com/help/how-mapbox-works/access-tokens/" target="_blank" rel="noopener noreferrer">',
Expand Down
Loading