Overview
The ZIGI QR code is the core element of the payment process. Customers scan this code with their ZIGI app to complete payments. This guide covers how to upload, preview, and manage your QR code image.
QR Code Requirements
Before uploading your QR code, ensure it meets these requirements:
Supported Formats:These formats are validated in functions.php:164.
Only image files are accepted. The plugin validates the file type using wp_check_filetype_and_ext() to ensure security.
Image Best Practices
- Resolution: Minimum 300x300 pixels for clear scanning
- File Size: Keep under 500KB for fast loading
- Format: PNG recommended for best quality
- Content: Ensure the QR code is clear and not distorted
- Background: Use a solid, contrasting background
Upload Interface
The QR upload interface is implemented as a custom button field type in the plugin settings (paga-con-zigi.php:148-160).
// Source: paga-con-zigi.php:148-160
'upload_qr' => array(
'title' => __('Seleccionar Imagen QR', 'paga-con-zigi'),
'type' => 'button',
'class' => 'kwp_upload_image_button button-secondary',
'label' => 'axa',
'description' => __('Aquí debes subir la imagen QR.', 'paga-con-zigi'),
'desc_tip' => true,
),
'preview_qr' => array(
'title' => '',
'type' => 'hidden',
'class' => 'kwp_preview_qr',
)
Uploading Your QR Code
Navigate to Settings
Go to WooCommerce → Settings → Payments → Paga con ZIGI
Find the QR Upload Section
Scroll down to the “Seleccionar Imagen QR” field. You’ll see an upload area with the text “Sube el QR aquí”
Click to Upload
Click the “Seleccionar Imagen QR” button. This will open the WordPress Media Library
Select or Upload Image
Either:
- Select an existing image from your Media Library
- Upload a new image by dragging and dropping or clicking “Upload files”
Confirm Selection
Click “Usar esta imagen” to confirm your selection
Preview and Save
The image will appear in the preview area below. Click “Save changes” at the bottom of the page
Upload Implementation
The upload functionality uses the WordPress Media Library integration (assets/woopro.js:3-23):
// Source: assets/woopro.js:3-23
$( document ).on( 'click', '.kwp_upload_image_button', function( e ) {
e.preventDefault();
var button = $( this ),
aw_uploader = wp.media({
title: 'Imagen Personalizada',
library : {
uploadedTo : wp.media.view.settings.post.id,
type : 'image'
},
button: {
text: 'Usar esta imagen'
},
multiple: false
}).on( 'select', function() {
var attachment = aw_uploader.state().get( 'selection' ).first().toJSON();
$( '.preview_area' ).html('<img src="'+attachment.url+'" class="upload_qr" style="display: block; padding: 10px; width: 200px;border: 1px solid;margin-bottom: 10px;"><button class="remove_qr button-secondary" type="button">Eliminar</button>');
$( '.kwp_preview_qr' ).val( attachment.url );
})
.open();
});
The Media Library integration allows you to reuse existing images or upload new ones, making it easy to update your QR code if needed.
Preview Area
After uploading, the QR code appears in a preview section (paga-con-zigi.php:196-217):
// Source: paga-con-zigi.php:203-216
<div class="preview_area">
<?php
$options = get_option('woocommerce_zigi_payment_settings');
if (isset($options['preview_qr']) && !empty($options['preview_qr'])) {
?>
<img src="<?php echo esc_attr($options['preview_qr']); ?>"
class="upload_qr"
alt="Preview Icon"
loading="lazy">
<button class="remove_qr button-secondary" type="button">
<?php esc_html_e('Eliminar', 'paga-con-zigi'); ?>
</button>
<?php } ?>
</div>
The preview shows:
- The uploaded QR code image (200px width)
- A “Eliminar” (Remove) button to delete the image
Removing the QR Code
To remove the current QR code:
- Click the “Eliminar” button below the preview image
- The image will be removed from the preview
- Click “Save changes” to persist the removal
// Source: assets/woopro.js:25-30
$( document ).on( 'click', '.remove_qr', function( e ) {
e.preventDefault();
$( '.upload_qr' ).remove();
$( '.kwp_preview_qr' ).val('');
$( this ).remove();
});
Removing the QR code without uploading a replacement will prevent the payment popup from displaying the QR code to customers.
QR Code Display to Customers
The uploaded QR code is displayed in the payment popup (functions.php:32-38):
// Source: functions.php:32-38
<?php
if (isset($options['preview_qr']) && !empty($options['preview_qr'])) {
?>
<img src="<?php echo esc_url($options['preview_qr']); ?>"
class="popup-qr"
alt="Preview Image"
loading="lazy" />
<?php } ?>
When customers:
- Select “Paga con ZIGI” at checkout
- Click to proceed with payment
- A popup modal appears showing your QR code
- Customers scan the code with their ZIGI app
Custom Upload Directory
For security and organization, customer payment receipts are stored in a custom directory (functions.php:101-126):
// Source: functions.php:102-125
function zigi_payment_qr_code_upload_dir($dirs)
{
$custom_subdir = '/zigi-payment-qrcode';
$new_path = $dirs['basedir'] . $custom_subdir;
$new_url = $dirs['baseurl'] . $custom_subdir;
// Create folder if it doesn't exist (using WP_Filesystem)
global $wp_filesystem;
if (! $wp_filesystem) {
require_once ABSPATH . '/wp-admin/includes/file.php';
WP_Filesystem();
}
if (! $wp_filesystem->is_dir($new_path)) {
$wp_filesystem->mkdir($new_path);
$wp_filesystem->put_contents($new_path . '/index.html', '', FS_CHMOD_FILE);
}
return array_merge($dirs, array(
'path' => $new_path,
'url' => $new_url,
'subdir' => $custom_subdir,
));
}
The admin QR code uses the standard WordPress Media Library. The custom directory is only used for customer-uploaded payment receipts.
Security Considerations
The plugin implements several security measures:
File Type Validation
// Source: functions.php:161-166
$check = wp_check_filetype_and_ext($file['tmp_name'], $file['name']);
$ext = $check['ext'];
if (!in_array($ext, ['jpg', 'jpeg', 'png', 'gif'])) {
wp_send_json_error('error: Tipo de archivo inválido. Solo se permiten JPG, JPEG y PNG.', 400);
}
Nonce Verification
For customer uploads (functions.php:132-135):
$wp_nonce = isset($_POST['nonce']) ? sanitize_text_field(wp_unslash($_POST['nonce'])) : '';
if (!$wp_nonce || !wp_verify_nonce($wp_nonce, 'zigi_payment_qr_nonce')) {
wp_send_json_error('Nonce inválido.', 403);
}
File Upload Validation
// Source: functions.php:157-159
if (!is_uploaded_file($file['tmp_name'])) {
wp_send_json_error('Carga inválida.', 400);
}
Troubleshooting
Possible causes:
- QR code not saved properly
- Image URL is invalid
- File was deleted from server
Solution:
- Re-upload the QR code
- Check the preview area shows the image
- Save settings again
Possible causes:
- JavaScript conflicts with other plugins
- WordPress media scripts not loaded
Solution:
- Check browser console for JavaScript errors
- Temporarily disable other plugins to identify conflicts
- Ensure WordPress is up to date
Upload Fails with Error
Possible causes:
- File size exceeds server limits
- File type not supported
- Permission issues with uploads directory
Solution:
- Check file meets requirements (JPG, PNG, or GIF)
- Verify PHP
upload_max_filesize setting
- Check WordPress uploads directory permissions (should be 755)
Testing Your QR Code
Save Settings
After uploading, ensure you click “Save changes”
Add Product to Cart
Add a product to your cart and proceed to checkout
Select ZIGI Payment
Choose “Paga con ZIGI” as the payment method
Verify QR Display
The payment popup should appear showing your QR code clearly
Test Scanning
Use your ZIGI app to scan the code and verify it works correctly
Always test the complete payment flow after uploading or changing your QR code to ensure customers can successfully complete payments.