Shortcode Usage
The Direct plugin provides powerful shortcodes that allow you to display custom payment forms anywhere on your website. There are two main shortcodes available for different purposes.
Primary Shortcode: Payment Forms
Purpose
This shortcode displays a custom payment form created in the Direct plugin admin area. Each payment form has a unique ID that you specify in the shortcode.
How to Get the ID
- Create a payment form in Direct → All Payment Forms
- Note the form ID from the URL when editing (e.g., post=123)
- Or copy the complete shortcode from the Shortcode column in the forms list
- Or copy from the shortcode meta box when editing a form
Secondary Shortcode: Product Page Quick Buy
Purpose
This shortcode displays the quick buy button functionality that normally appears on product pages. It’s useful when you want to add quick purchase options in custom locations.
Important Notes
- Only works on WooCommerce product pages
- Uses the same settings as configured in Product Page settings
- Automatically detects the current product
- Respects user login status and configured display rules
Where to Use Shortcodes
📄 Pages and Posts
Add shortcodes directly in the WordPress content editor:
[direct id=”123″]
Best for: Landing pages, product promotions, sales funnels
Tip: Use the Block Editor’s “Shortcode” block for better visual editing
🎛️ Widgets
Use shortcodes in text widgets or custom HTML widgets:
[direct id=”123″]
Best for: Sidebars, footer areas, header promotions
Locations: Any widget area that supports HTML/shortcodes
📋 Page Builders
Most popular page builders support shortcodes:
- Elementor: Use the “Shortcode” widget
- Beaver Builder: Add “HTML” or “Text” module
- Divi: Use the “Code” module
- Visual Composer: Add “Raw HTML” element
- Gutenberg: Use the “Shortcode” block
🎨 Theme Templates
Add shortcodes directly in PHP theme files:
<?php echo do_shortcode(‘[direct id=”123″]’); ?>
Best for: Custom theme development, specific template files
Common locations: header.php, footer.php, custom page templates
Shortcode Behavior and Features
🔐 User Detection
- Automatically detects if user is logged in or guest
- Shows appropriate form fields based on user status
- Respects form-specific logged-in user settings
- Handles user permissions and access control
🛡️ Security Integration
- Full CSRF protection for all form submissions
- Email verification with OTP codes (if enabled)
- Secure payment gateway integration
- Session management and user authentication
📱 Responsive Design
- Automatically adapts to container width
- Mobile-optimized form layouts
- Touch-friendly buttons and inputs
- Consistent styling across devices
⚡ AJAX Functionality
- Real-time form validation
- Smooth email verification process
- Loading indicators during processing
- No page refreshes for better UX
Common Use Cases
Landing Page Integration
Create dedicated landing pages for marketing campaigns:
- Create a new WordPress page
- Add compelling sales content
- Insert payment form shortcode:
[direct id="123"] - Publish and use in marketing campaigns
Email Marketing
Direct customers to pages with embedded payment forms:
- Create product-specific pages with shortcodes
- Use tracking parameters in URLs for analytics
- A/B test different form configurations
- Measure conversion rates from email campaigns
Popup Integration
Use shortcodes in popup plugins for exit-intent offers:
- Compatible with popular popup plugins
- Perfect for last-chance offers
- Minimal form fields for quick conversion
- Mobile-friendly popup displays
Membership Sites
Embed forms in restricted content areas:
- Member-only product offers
- Tiered pricing for different membership levels
- Integration with membership plugins
- Exclusive product access
Advanced Usage Tips
Multiple Forms Strategy
- A/B Testing: Create multiple forms with different styling/content
- Product Bundles: Different forms for different product combinations
- Seasonal Campaigns: Dedicated forms for holiday promotions
- Audience Targeting: Different forms for different customer segments
Performance Considerations
- Loading Scripts: Forms load necessary CSS and JavaScript only when used
- Caching: Test with your caching plugins to ensure forms work properly
- Image Optimization: Optimize product images displayed in forms
- Gateway Speed: Some payment gateways load faster than others
Troubleshooting Shortcodes
Shortcode Not Displaying
- Verify the form ID exists and is published
- Check if the shortcode syntax is correct
- Ensure you have required permissions
- Test with a different form ID
Form Not Working
- Check if WooCommerce is active
- Verify payment gateway is properly configured
- Test email verification settings
- Clear any caching plugins
Styling Issues
- Check theme compatibility
- Verify CSS conflicts with browser inspector
- Test on different devices and browsers
- Adjust form width settings if needed
Shortcode Attributes
Future Enhancement: Attribute support may be added in future versions to allow shortcode-specific overrides of form settings.