Introduction
Dear Divi Maniacs, if you thought Divi was just a page builder for creating stunning layouts, get ready to discover a secret feature that can turn your e-commerce site into a conversion powerhouse. By combining Divi, Dynamic Content, and a bit of custom PHP, you can adjust prices, discounts, or promotions in real time based on user behavior. This isn’t an officially documented feature—but advanced Divimania users can leverage it creatively.
How It Works: Customizing Prices Based on Specific Actions
Imagine being able to:
- Show progressive discounts if a user stays on the page for more than 30 seconds.
- Display different prices based on the user’s location (e.g., premium pricing for high-income regions).
- Trigger urgency messages (“Only 2 left!”) only for users who clicked “Add to Cart” but didn’t complete checkout.
With Divi, this is possible without extra plugins, using:
- Divi Dynamic Content (to inject custom data).
- PHP Cookies/Sessions (to track actions like time spent or clicks).
- Custom CSS/JS (to animate changes smoothly).
Practical Example: A Discount That Appears After Scrolling
Here’s how to implement it:
Step 1: Add a Text Module with Dynamic Content
- Use the “Dynamic Content” field in the text module and select “Custom Field.”
- Insert a custom shortcode (e.g.,
[dynamic_price]
) that calls a PHP function.
Step 2: Create a PHP Function to Handle the Logic
In your child theme’s functions.php
, add:
add_shortcode('dynamic_price', function() { if (isset($_COOKIE['user_scrolled']) && $_COOKIE['user_scrolled'] == 'true') { return '<span class="original-price">€99</span> <span class="discounted-price">€79</span>'; } else { return '<span class="original-price">€99</span>'; } });
Step 3: Enable Tracking with JavaScript
Add this JS in a Divi Code Module:
document.addEventListener('scroll', function() { if (window.scrollY > 500) { document.cookie = "user_scrolled=true; path=/"; // Update the price without reloading the page if (document.querySelector('[data-dynamic="price"]')) { fetch(window.location.href) // Simulate dynamic content refresh .then(response => response.text()) .then(html => { const newContent = new DOMParser().parseFromString(html, 'text/html'); const dynamicElement = newContent.querySelector('[data-dynamic="price"]'); if (dynamicElement) { document.querySelector('[data-dynamic="price"]').innerHTML = dynamicElement.innerHTML; } }); } } });
Why This Feature Is a Game-Changer for E-commerce
- A/B Testing Without Plugins: Test pricing strategies directly in Divi.
- Indirect SEO Boost: Pages that react to user behavior reduce bounce rates and increase engagement.
- Unlimited Flexibility: Also works for countdown timers, dynamic bundles, or VIP content for logged-in users.
Pro Tip for Divimania Readers
Pair this technique with Divi Ajax Cart to update the cart in real time when prices change. Just hook into woocommerce_before_calculate_totals
and adjust prices based on cookies!
Want the full code and a downloadable example? Leave a comment on Divimania.com, and we’ll share the package!
Final Thoughts
Divi hides incredible potential for e-commerce—you just need to think beyond prebuilt modules. With a little code and the right strategy, you can create a hyper-personalized shopping experience that sets you apart.
Ready to experiment? 🚀
(SEO-optimized for keywords like “Divi e-commerce dynamic pricing,” “custom pricing with Divi,” “hidden Divi features”)
What do you think? Would you like a step-by-step tutorial for another use case? Let us know in the comments! 😊