<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chris Kelechukwu on Medium]]></title>
        <description><![CDATA[Stories by Chris Kelechukwu on Medium]]></description>
        <link>https://medium.com/@eldritchchris?source=rss-60b2c28ca03e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kt3H0EJCjFsu-uum3QU1Kw.jpeg</url>
            <title>Stories by Chris Kelechukwu on Medium</title>
            <link>https://medium.com/@eldritchchris?source=rss-60b2c28ca03e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:06:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eldritchchris/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[I Spent Days Debugging a BricksForge Pro Forms Webhook — Here’s What Was Actually Broken]]></title>
            <link>https://medium.com/@eldritchchris/i-spent-days-debugging-a-bricksforge-pro-forms-webhook-heres-what-was-actually-broken-69c34b0b85e3?source=rss-60b2c28ca03e------2</link>
            <guid isPermaLink="false">https://medium.com/p/69c34b0b85e3</guid>
            <category><![CDATA[wordpress-plugins]]></category>
            <category><![CDATA[wordpress-development]]></category>
            <category><![CDATA[wordpress]]></category>
            <dc:creator><![CDATA[Chris Kelechukwu]]></dc:creator>
            <pubDate>Wed, 11 Mar 2026 23:17:12 GMT</pubDate>
            <atom:updated>2026-03-11T23:17:12.832Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w02Ch31MGJTZ7VdfWupv_w.png" /></figure><p>There’s a specific kind of frustration that comes from spending days on something that should take an afternoon. You’ve checked everything twice. The setup looks right. The docs say it should work. And yet — nothing.</p><p>That was me recently, trying to get a BricksForge Pro Forms webhook to talk to n8n. What I eventually found wasn’t a misconfiguration, a caching issue, or anything on my end. It was two genuine bugs sitting in one line of BricksForge’s own webhook.php. Here’s the full breakdown.</p><h3>The Setup</h3><p>The form in question was a multi-step Pro Forms form with conditional wrappers — different fields showing based on whether the user selected Privat, BRF, or Företag (Swedish for private individual, housing association, or company). It had radio buttons, checkboxes, a file upload, and the usual contact fields. On submission, it needed to fire a webhook to an n8n workflow.</p><p>Straightforward enough on paper.</p><h3>Symptom One: The 500</h3><p>The first thing that happened was a flat-out 500 Internal Server Error on submission. The form wouldn’t go through at all. The frontend just showed a generic WordPress critical error page and the browser console logged:</p><pre>POST https://yoursite.com/wp-json/bricksforge/v1/form_submit 500 (Internal Server Error)<br>SyntaxError: Unexpected token &#39;&lt;&#39;, &quot;&lt;!DOCTYPE &quot;... is not valid JSON</pre><p>WordPress was returning an HTML error page instead of JSON — which means PHP crashed before it could send a proper response.</p><p>Digging into the PHP error log (CloudPanel puts it at /home/[user]/logs/[domain]-error.log if you&#39;re on a VPS + Cloudpanel setup like mine) revealed this:</p><pre>PHP Fatal error: Uncaught TypeError: explode(): Argument #2 ($string) <br>must be of type string, array given in <br>.../bricksforge/includes/elements/pro-forms/actions/webhook.php:82</pre><p>Line 82. explode() received an array instead of a string. That&#39;s the crash.</p><h3>Symptom Two: Garbled Keys</h3><p>After patching the crash, the form submitted fine — no errors, redirected to the thank you page. But when I looked at what actually arrived in n8n, the payload was completely wrong:</p><pre>{<br>  &quot;privat&quot;: &quot;privat&quot;,<br>  &quot;John Smith&quot;: &quot;John Smith&quot;,<br>  &quot;john@example.com&quot;: &quot;john@example.com&quot;,<br>  &quot;timing[0]&quot;: &quot;72h&quot;,<br>  &quot;services[0]&quot;: &quot;Elinstallation&quot;<br>}</pre><p>The keys and values were identical. type wasn&#39;t type anymore — it had become privat, which was the <em>value</em> of the type field. Every key had been resolved to its corresponding field value, so the entire payload was nonsense.</p><h3>What’s Actually Going On</h3><p>Both issues trace back to the same single line in webhook.php. Here it is:</p><pre>// Line 82<br>$keys = explode(&#39;.&#39;, $form-&gt;get_form_field_by_id($d[&#39;key&#39;], null, null, null, null, false));</pre><p>To understand why this is wrong, you need to understand what get_form_field_by_id() does. It takes an ID, looks it up in the submitted form data, and returns the current value of that field. It&#39;s designed for resolving {{tokens}} in webhook values — so when you write {{email}}, it finds the email field and returns what the user typed.</p><p>That’s the right behaviour for <strong>values</strong>.</p><p>But this line is calling it on <strong>keys</strong> — the destination field names in your webhook mapping. Keys like type, full_name, email are meant to be used as-is. They&#39;re not references to form fields. They&#39;re just the names you want to appear in your webhook payload.</p><p>By running them through get_form_field_by_id(), BricksForge is treating your key names as field IDs and resolving them to their current values. So type (which matches the hidden field storing privat) becomes privat. full_name (which matches the name field) becomes whatever the user typed. The key becomes the value.</p><p>That’s Bug #2 — keys being resolved as field lookups.</p><p>Bug #1 is a direct consequence of the same mistake. The form has a checkbox field with the ID services. When get_form_field_by_id(&#39;services&#39;) runs, it returns the checkbox selections as a <strong>PHP array</strong> — because that&#39;s what checkbox fields return. Then explode() receives that array as its second argument, which it can&#39;t handle, and PHP dies.</p><h3>The Fix</h3><p>The fix is genuinely one line:</p><pre>// Before (line 82 in webhook.php):<br>$keys = explode(&#39;.&#39;, $form-&gt;get_form_field_by_id($d[&#39;key&#39;], null, null, null, null, false));</pre><pre>// After:<br>$keys = explode(&#39;.&#39;, (string)$d[&#39;key&#39;]);</pre><p>Stop calling get_form_field_by_id() on the key entirely. Just use $d[&#39;key&#39;] directly as a string. Keys are literal destination names from your webhook mapping config — they never needed to be looked up in the first place.</p><p>This one change fixes both bugs at once. No more fatal error, no more garbled keys.</p><h3>Bonus Issue: timing[0] Instead of timing</h3><p>With both bugs fixed, there was still one more annoyance. Radio button and single-selection checkbox values were arriving at n8n with bracket notation:</p><pre>timing[0]=72h<br>services[0]=Elinstallation</pre><p>Instead of the clean:</p><pre>timing=72h<br>services=Elinstallation</pre><p>This happens because Pro Forms stores field values internally as PHP arrays even for single selections. When http_build_query() serialises them into form-data, it adds [0] to indicate the array index. Technically correct PHP behaviour, but annoying to work with downstream.</p><p>The fix is to flatten any single-element array to its scalar value before the payload is built. Add this just before the apply_filters(&#39;bricksforge/pro_forms/webhook_before_send&#39; line:</p><pre>$webhook_data = array_map(function($value) {<br>    if (is_array($value) &amp;&amp; count($value) === 1) {<br>        return reset($value);<br>    }<br>    return $value;<br>}, $webhook_data);</pre><p>This only flattens arrays with exactly one item. If a user selects multiple checkboxes, those still arrive as services[0], services[1] etc. — which is the correct behaviour for multi-select.</p><h3>Making the Fix Stick</h3><p>The obvious problem with editing a plugin file directly is that BricksForge updates will overwrite it. On a live production site that’s not acceptable — a silent update breaks the form with no warning.</p><p>The solution is a Must-Use plugin. Files in /wp-content/mu-plugins/ are never touched by plugin updates, can&#39;t be deactivated from the WordPress admin, and load before everything else. A mu-plugin that patches webhook.php on every load is self-healing — if an update reverts the file, the patch is re-applied automatically on the next request.</p><p>The logic looks like this:</p><pre>add_action(&#39;plugins_loaded&#39;, function () {<br>    $file = WP_CONTENT_DIR . &#39;/plugins/bricksforge/includes/elements/pro-forms/actions/webhook.php&#39;;<br>    $contents = file_get_contents($file);</pre><pre>    // Skip if already patched<br>    if (strpos($contents, &#39;// fixed&#39;) !== false) return;</pre><pre>    $old = &#39;$keys = explode(\&#39;.\&#39;, $form-&gt;get_form_field_by_id($d[\&#39;key\&#39;], null, null, null, null, false));&#39;;<br>    $new = &#39;// fixed&#39; . PHP_EOL . &#39;$keys = explode(\&#39;.\&#39;, (string)$d[\&#39;key\&#39;]);&#39;;</pre><pre>    file_put_contents($file, str_replace($old, $new, $contents));<br>}, 1);</pre><p>The real implementation I’m running also handles the case where a previous version of the patch is already applied, logs a warning to the PHP error log if the target string can’t be found (e.g. after a major BricksForge refactor), and gracefully bails if file permissions prevent writing. But the core idea is above.</p><h3>Where Things Stand</h3><p>I’ve reported both bugs to the BricksForge team. The fix is genuinely trivial as it is just one line change, so hopefully it lands in the next release. Until then the mu-plugin approach works cleanly on production.</p><p>If you’re hitting either of these issues, the symptoms are pretty specific:</p><ul><li><strong>500 on submission + </strong><strong>explode() array in PHP logs</strong> → you have a checkbox field and this is your bug</li><li><strong>Keys and values are identical in your webhook payload</strong> → same root cause, different symptom</li></ul><p>Both fixed by the same one-liner.</p><p><em>Building on Bricks + BricksForge and hit something similar? Drop a comment — happy to help debug.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69c34b0b85e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Dual Pricing Functionality in WooCommerce (Retail vs. Wholesale)]]></title>
            <link>https://medium.com/@eldritchchris/building-a-dual-pricing-functionality-in-woocommerce-retail-vs-wholesale-d7749328646e?source=rss-60b2c28ca03e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7749328646e</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[wordpress-web-development]]></category>
            <category><![CDATA[wordpress-development]]></category>
            <category><![CDATA[woocommerce-development]]></category>
            <dc:creator><![CDATA[Chris Kelechukwu]]></dc:creator>
            <pubDate>Mon, 24 Feb 2025 11:15:14 GMT</pubDate>
            <atom:updated>2025-02-24T11:20:35.834Z</atom:updated>
            <content:encoded><![CDATA[<p>Building a Dual Pricing Functionality in WooCommerce (Retail vs. Wholesale)</p><p>Hey everyone, Chris here. At my last job, I built a feature for a client (client details remain confidential, of course) that allowed their WooCommerce store to offer both retail (single unit) and wholesale (carton) pricing. Now, I have no idea if there’s a plugin that does this (I didn’t check, sue me 😒). I have a philosophy when it comes to developing with WordPress; the fewer the plugins, the better. That invariably means I code most features myself to keep the website lean and fast. Now that that’s out of the way, I’ll stop yapping and tell you exactly how I did it.</p><p>1. Adding the “Carton Price” Field for Simple Products<br>I kicked things off by inserting a custom field into the WooCommerce pricing settings. I used WooCommerce’s native woocommerce_wp_text_input() function to create a number field labeled “Carton Price ($).” This lets the store manager enter a wholesale price right in the product edit screen. With proper attributes for step and min value, it’s both user-friendly and foolproof.</p><p>2. Extending to Variable Products with JavaScript<br>Variable products can be tricky since each variation might need its own wholesale price. Instead of searching for a plugin solution, I wrote a simple jQuery script that runs on the product edit page. For every variation, the script appends a new “Carton Price” field in the variable pricing area. This way, every variation can have its individual wholesale price, cleanly and efficiently if I do say so myself.</p><p>3. Saving the Custom Field Data<br>Of course, displaying fields isn’t enough; you have to save the data too. I hooked into WooCommerce’s saving process (using woocommerce_process_product_meta and woocommerce_save_product_variation) to capture and store the carton price. This involves checking if a value exists, sanitizing it, and then saving it as post meta. That way, the wholesale price persists even after product updates.</p><p>4. Displaying Buy Option Buttons on the Product Page<br>To let customers choose between retail and wholesale pricing, I added two buttons on the single product page, one for “Buy a Single Item” and another for “Buy a Carton.” I styled these buttons with inline CSS (yes, the CSS is included right there) and added icons using SVGs that I had uploaded to the website media. A bit of JavaScript toggles between the two options, ensuring a smooth, interactive experience.</p><p>5. Passing the Selection into the Cart Data<br>When a customer clicks one of those buttons, their choice (either ‘single’ or ‘carton’) is captured via the woocommerce_add_cart_item_data hook. If they select “carton,” the code retrieves the wholesale price I saved earlier and attaches it to the cart item data. This ensures that the correct pricing info is carried through to checkout.</p><p>6. Dynamically Adjusting the Cart Item Price<br>Right before WooCommerce calculates the totals, my function loops through the cart items. For any item flagged as a carton purchase, the product’s price is dynamically updated to the wholesale rate. This seamless price adjustment means that the cart always reflects the right pricing without any manual intervention.</p><p>7. Updating the Price Display on the Product Page<br>Lastly, to give immediate feedback to the shopper, I added a script that updates the price display on the product page based on their selection. When “Buy a Carton” is clicked, the displayed price changes to the wholesale price, and when they switch back, it reverts to the retail price. This real-time update is crucial for clarity during the buying process.</p><p>The Complete Code is Below<br>You can find the entire unified code snippet below this guide. It includes all the parts I just explained, from adding custom fields and saving data to updating the cart and price displays. Feel free to embed this into your child theme or, if you prefer a cleaner approach, use a code snippets plugin. Personally, I like the latter because I can keep my theme files pristine. Of course the code below has been arranged just for this post 🤧 (trust me you don’t want to see the original code. Spaghetti code would be nice)</p><p>That’s how I built this dual pricing feature from scratch; no bloated plugins, just pure custom code. It’s a testament to the approach of keeping things minimal, lean, and efficient. I spent a couple of days hammering through the details (had a few migraines, not gonna lie), but it was totally worth it. If you’re looking to offer dual pricing in your WooCommerce store and want full control over your code, I hope you find this guide as straightforward and practical as I did.</p><p>Happy coding, and feel free to share your thoughts or ask any questions!</p><p>Cheers!<br>Chris Kelechukwu</p><pre>&lt;?php<br>/**<br> * Unified WooCommerce Extension for Dual Pricing: Retail vs Wholesale<br> *<br> * This code adds a custom &quot;Carton Price&quot; field to the product pricing settings (for both simple and variable products),<br> * displays two buy option buttons on the product page (with icons from a placeholder website),<br> * passes the chosen option into the cart data, adjusts the cart item price if the carton option is selected,<br> * and updates the price display on the single product page.<br> *<br> * Place this code in your child theme&#39;s functions.php file or add it via your Code Snippets plugin.<br> */<br><br>/* 1. Add Carton Price Field to Simple Products */<br>function add_carton_price_fields() {<br>    woocommerce_wp_text_input( array(<br>        &#39;id&#39;                =&gt; &#39;_carton_price&#39;,<br>        &#39;label&#39;             =&gt; __( &#39;Carton Price ($)&#39;, &#39;woocommerce&#39; ),<br>        &#39;description&#39;       =&gt; __( &#39;Enter the price for buying a carton.&#39;, &#39;woocommerce&#39; ),<br>        &#39;type&#39;              =&gt; &#39;number&#39;,<br>        &#39;desc_tip&#39;          =&gt; true,<br>        &#39;custom_attributes&#39; =&gt; array( &#39;step&#39; =&gt; &#39;0.01&#39;, &#39;min&#39; =&gt; &#39;0&#39; ),<br>    ) );<br>}<br>add_action( &#39;woocommerce_product_options_pricing&#39;, &#39;add_carton_price_fields&#39; );<br><br>/* 2. Add Carton Price Field to Variable Product Variations */<br>function add_carton_price_fields_for_variations() {<br>    ?&gt;<br>    &lt;script type=&quot;text/javascript&quot;&gt;<br>        jQuery(document).ready(function($) {<br>            $(&#39;.woocommerce_variation&#39;).each(function() {<br>                var variation_id = $(this).data(&#39;variation_id&#39;);<br>                $(&#39;.variable_pricing&#39;, this).append(`<br>                    &lt;p class=&quot;form-field _carton_price_field&quot;&gt;<br>                        &lt;label for=&quot;_carton_price[${variation_id}]&quot;&gt;&lt;?php echo esc_html__( &#39;Carton Price ($)&#39;, &#39;woocommerce&#39; ); ?&gt;&lt;/label&gt;<br>                        &lt;input type=&quot;number&quot; class=&quot;short wc_input_price&quot; name=&quot;_carton_price_variations[${variation_id}]&quot; value=&quot;&quot; placeholder=&quot;&quot; step=&quot;0.01&quot; min=&quot;0&quot;&gt;<br>                    &lt;/p&gt;<br>                `);<br>            });<br>        });<br>    &lt;/script&gt;<br>    &lt;?php<br>}<br>add_action( &#39;woocommerce_product_after_variable_attributes_js&#39;, &#39;add_carton_price_fields_for_variations&#39; );<br><br>/* 3. Save the Carton Price Field Data */<br>function save_carton_price( $post_id ) {<br>    if ( isset( $_POST[&#39;_carton_price&#39;] ) ) {<br>        update_post_meta( $post_id, &#39;_carton_price&#39;, sanitize_text_field( $_POST[&#39;_carton_price&#39;] ) );<br>    }<br>    if ( isset( $_POST[&#39;_carton_price_variations&#39;] ) ) {<br>        foreach ( $_POST[&#39;_carton_price_variations&#39;] as $variation_id =&gt; $carton_price ) {<br>            update_post_meta( $variation_id, &#39;_carton_price&#39;, sanitize_text_field( $carton_price ) );<br>        }<br>    }<br>}<br>add_action( &#39;woocommerce_process_product_meta&#39;, &#39;save_carton_price&#39; );<br>add_action( &#39;woocommerce_save_product_variation&#39;, &#39;save_carton_price&#39;, 10, 2 );<br><br>/* 4. Display Buy Option Buttons (Single vs Carton) on the Product Page */<br>function display_buy_option_with_carton() {<br>    // Define inline styles for active and inactive buttons<br>    $activeButtonStyle = &quot;display: inline-block; background-color: #dd9402; color: white; padding: 10px 20px; cursor: pointer; border: 1px solid #dd9402; border-radius: 3px; font-size: 0.6rem; text-transform: uppercase; margin-bottom: 1.2rem;&quot;;<br>    $buttonStyle       = &quot;display: inline-block; background-color: transparent; color: black; padding: 10px 20px; cursor: pointer; border: 1px solid #000; border-radius: 3px; font-size: 0.6rem; text-transform: uppercase; margin-bottom: 1.2rem; padding-left: 1.2rem; opacity: 0.4;&quot;;<br>    // Use placeholder website URLs for icons<br>    $singleItemIconUrl = &#39;https://placeholderwebsite.com/single-item.svg&#39;;<br>    $cartonIconUrl     = &#39;https://placeholderwebsite.com/carton.svg&#39;;<br>    ?&gt;<br>    &lt;div id=&quot;buy_options_container&quot; style=&quot;margin: 1.2rem 0;&quot;&gt;<br>        &lt;button type=&quot;button&quot; id=&quot;buy_single&quot; class=&quot;buy_option_button&quot; style=&quot;&lt;?php echo $activeButtonStyle; ?&gt;&quot; onclick=&quot;setBuyOption(&#39;single&#39;)&quot;&gt;<br>            &lt;img src=&quot;&lt;?php echo $singleItemIconUrl; ?&gt;&quot; alt=&quot;Single Item&quot; class=&quot;buy_option_icon&quot;&gt;<br>            &amp;nbsp; Buy a Single Item<br>        &lt;/button&gt;<br>        &lt;button type=&quot;button&quot; id=&quot;buy_carton&quot; class=&quot;buy_option_button&quot; style=&quot;&lt;?php echo $buttonStyle; ?&gt;&quot; onclick=&quot;setBuyOption(&#39;carton&#39;)&quot;&gt;<br>            &lt;img src=&quot;&lt;?php echo $cartonIconUrl; ?&gt;&quot; alt=&quot;Carton&quot; class=&quot;buy_option_icon&quot;&gt;<br>            &amp;nbsp; Buy a Carton<br>        &lt;/button&gt;<br>        &lt;input type=&quot;hidden&quot; name=&quot;buy_option&quot; id=&quot;buy_option&quot; value=&quot;single&quot;&gt;<br>    &lt;/div&gt;<br>    &lt;style&gt;<br>        .buy_option_icon {<br>            width: 1.2rem;<br>            height: 1.2rem;<br>            filter: invert(0%);<br>        }<br>        .buy_option_button.active .buy_option_icon {<br>            filter: invert(100%);<br>        }<br>    &lt;/style&gt;<br>    &lt;script&gt;<br>        function setBuyOption(option) {<br>            var singleButton = document.getElementById(&#39;buy_single&#39;);<br>            var cartonButton = document.getElementById(&#39;buy_carton&#39;);<br>            // Reset both buttons<br>            singleButton.style = &quot;&lt;?php echo $buttonStyle; ?&gt;&quot;;<br>            cartonButton.style = &quot;&lt;?php echo $buttonStyle; ?&gt;&quot;;<br>            singleButton.classList.remove(&quot;active&quot;);<br>            cartonButton.classList.remove(&quot;active&quot;);<br>            // Activate the selected option<br>            if ( option === &#39;single&#39; ) {<br>                singleButton.style = &quot;&lt;?php echo $activeButtonStyle; ?&gt;&quot;;<br>                singleButton.classList.add(&quot;active&quot;);<br>                document.getElementById(&#39;buy_option&#39;).value = &#39;single&#39;;<br>            } else if ( option === &#39;carton&#39; ) {<br>                cartonButton.style = &quot;&lt;?php echo $activeButtonStyle; ?&gt;&quot;;<br>                cartonButton.classList.add(&quot;active&quot;);<br>                document.getElementById(&#39;buy_option&#39;).value = &#39;carton&#39;;<br>            }<br>        }<br>        window.onload = function() {<br>            setBuyOption(&#39;single&#39;);<br>        };<br>    &lt;/script&gt;<br>    &lt;?php<br>}<br>add_action( &#39;woocommerce_before_add_to_cart_button&#39;, &#39;display_buy_option_with_carton&#39; );<br><br>/* 5. Pass the Buy Option (Single vs Carton) into Cart Item Data */<br>function carton_price_option_to_cart_item_data( $cart_item_data, $product_id, $variation_id ) {<br>    if ( isset( $_POST[&#39;buy_option&#39;] ) ) {<br>        $buy_option = sanitize_text_field( $_POST[&#39;buy_option&#39;] );<br>        $cart_item_data[&#39;buy_option&#39;] = $buy_option;<br>        if ( &#39;carton&#39; === $buy_option ) {<br>            $price_id = $variation_id ? $variation_id : $product_id;<br>            $carton_price = get_post_meta( $price_id, &#39;_carton_price&#39;, true );<br>            if ( $carton_price ) {<br>                $cart_item_data[&#39;carton_price&#39;] = $carton_price;<br>            }<br>        }<br>    }<br>    return $cart_item_data;<br>}<br>add_filter( &#39;woocommerce_add_cart_item_data&#39;, &#39;carton_price_option_to_cart_item_data&#39;, 10, 3 );<br><br>/* 6. Adjust the Cart Item Price Based on the Buy Option */<br>function adjust_price_based_on_selection( $cart ) {<br>    if ( is_admin() &amp;&amp; ! defined( &#39;DOING_AJAX&#39; ) ) return;<br>    foreach ( $cart-&gt;get_cart() as &amp;$cart_item ) {<br>        if ( isset( $cart_item[&#39;buy_option&#39;] ) &amp;&amp; &#39;carton&#39; === $cart_item[&#39;buy_option&#39;] &amp;&amp; isset( $cart_item[&#39;carton_price&#39;] ) ) {<br>            $cart_item[&#39;data&#39;]-&gt;set_price( $cart_item[&#39;carton_price&#39;] );<br>        }<br>    }<br>}<br>add_action( &#39;woocommerce_before_calculate_totals&#39;, &#39;adjust_price_based_on_selection&#39;, 10 );<br><br>/* 7. Update the Price Display on the Single Product Page Dynamically */<br>function update_price_display_script() {<br>    global $product;<br>    $single_price = wc_get_price_to_display( $product );<br>    $carton_price = get_post_meta( $product-&gt;get_id(), &#39;_carton_price&#39;, true );<br>    ?&gt;<br>    &lt;script type=&quot;text/javascript&quot;&gt;<br>        jQuery(document).ready(function($) {<br>            function updatePriceDisplay(option) {<br>                var singlePrice = &lt;?php echo json_encode( wc_price($single_price) ); ?&gt;;<br>                var cartonPrice = &lt;?php echo json_encode( wc_price($carton_price) ); ?&gt;;<br>                var priceElement = $(&#39;.woocommerce-Price-amount.amount&#39;);<br>                if ( option === &#39;carton&#39; &amp;&amp; cartonPrice ) {<br>                    priceElement.html( cartonPrice );<br>                } else {<br>                    priceElement.html( singlePrice );<br>                }<br>            }<br>            $(&#39;#buy_single&#39;).on(&#39;click&#39;, function() {<br>                updatePriceDisplay(&#39;single&#39;);<br>            });<br>            $(&#39;#buy_carton&#39;).on(&#39;click&#39;, function() {<br>                updatePriceDisplay(&#39;carton&#39;);<br>            });<br>            // Set default display<br>            updatePriceDisplay(&#39;single&#39;);<br>        });<br>    &lt;/script&gt;<br>    &lt;?php<br>}<br>add_action( &#39;woocommerce_after_single_product&#39;, &#39;update_price_display_script&#39; );<br></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7749328646e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing WooCommerce Variations]]></title>
            <link>https://medium.com/@eldritchchris/enhancing-woocommerce-variations-d927267c48eb?source=rss-60b2c28ca03e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d927267c48eb</guid>
            <category><![CDATA[woocommerce]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[ecommerce-solution]]></category>
            <category><![CDATA[wordpress-development]]></category>
            <dc:creator><![CDATA[Chris Kelechukwu]]></dc:creator>
            <pubDate>Tue, 30 Apr 2024 09:32:06 GMT</pubDate>
            <atom:updated>2024-04-30T09:32:06.336Z</atom:updated>
            <content:encoded><![CDATA[<p>As a WordPress developer, I’ve had the pleasure of working on enhancing the WooCommerce platform to provide customers with a seamless post-purchase experience. One of the recent features I implemented is the ability to include custom webpage links in order confirmation emails for specific product variations. In this blog post, I’ll delve into the technical details of how I brought this functionality to life.</p><p>Custom Field Integration:<br>To initiate this project, I integrated a custom field for webpage links into the product variations on my WooCommerce website. This custom field allows me to input URLs pointing to the online practice materials associated with each variation. Here’s the code snippet I used to add the custom field:</p><pre>// Function to display custom field for online test link on variation edit<br>function wc_online_test_link_field( $loop, $variation_data, $variation ) {<br>    $online_test_link = get_post_meta( $variation-&gt;ID, &#39;_online_test_link&#39;, true );<br>    ?&gt;<br>    &lt;div class=&quot;form-row form-row-full&quot;&gt;<br>        &lt;label for=&quot;_online_test_link_&lt;?php echo esc_attr( $variation-&gt;ID ); ?&gt;&quot;&gt;<br>            &lt;?php esc_html_e( &#39;Online Test Link&#39;, &#39;your-text-domain&#39; ); ?&gt;<br>        &lt;/label&gt;<br>        &lt;input type=&quot;url&quot; class=&quot;input-text&quot; name=&quot;_online_test_link[&lt;?php echo esc_attr( $variation-&gt;ID ); ?&gt;]&quot; id=&quot;_online_test_link_&lt;?php echo esc_attr( $variation-&gt;ID ); ?&gt;&quot; value=&quot;&lt;?php echo esc_attr( $online_test_link ); ?&gt;&quot; placeholder=&quot;&lt;?php esc_attr_e( &#39;Enter online test link&#39;, &#39;your-text-domain&#39; ); ?&gt;&quot;&gt;<br>    &lt;/div&gt;<br>    &lt;?php<br>    // Add nonce field for security<br>    wp_nonce_field( &#39;woocommerce-save-data&#39;, &#39;woocommerce_meta_nonce&#39; );<br>}<br>add_action( &#39;woocommerce_variation_options&#39;, &#39;wc_online_test_link_field&#39;, 10, 3 );<br><br>// Save custom field for online test link on variation update<br>function wc_save_online_test_link( $variation_id ) {<br>    // Check if the form was submitted and nonce is valid<br>    if ( isset( $_POST[&#39;woocommerce_meta_nonce&#39;] ) &amp;&amp; wp_verify_nonce( $_POST[&#39;woocommerce_meta_nonce&#39;], &#39;woocommerce-save-data&#39; ) &amp;&amp; current_user_can( &#39;edit_products&#39; ) ) {<br>        // Check if the online test link field value is set in $_POST<br>        if ( isset( $_POST[&#39;_online_test_link&#39;] ) &amp;&amp; isset( $_POST[&#39;_online_test_link&#39;][ $variation_id ] ) ) {<br>            $online_test_link = sanitize_text_field( wp_unslash( $_POST[&#39;_online_test_link&#39;][ $variation_id ] ) );<br>            // Validate and update online test link meta<br>            if ( filter_var( $online_test_link, FILTER_VALIDATE_URL ) ) {<br>                update_post_meta( $variation_id, &#39;_online_test_link&#39;, esc_url_raw( $online_test_link ) );<br>            } else {<br>                update_post_meta( $variation_id, &#39;_online_test_link&#39;, &#39;&#39; );<br>                add_action( &#39;admin_notices&#39;, &#39;wc_online_test_link_admin_notice&#39; );<br>            }<br>        }<br>    }<br>}<br>add_action( &#39;woocommerce_save_product_variation&#39;, &#39;wc_save_online_test_link&#39;, 10, 1 );<br><br>// Display an admin notice if the online test link is invalid<br>function wc_online_test_link_admin_notice() {<br>    ?&gt;<br>    &lt;div class=&quot;notice notice-error is-dismissible&quot;&gt;<br>        &lt;p&gt;&lt;?php esc_html_e( &#39;The provided online test link is invalid. Please enter a valid URL.&#39;, &#39;your-text-domain&#39; ); ?&gt;&lt;/p&gt;<br>    &lt;/div&gt;<br>    &lt;?php<br>}</pre><p>Variation Edit Options Enhancement:<br>The custom field seamlessly integrates into the variation edit options within WooCommerce, empowering me to manage and update the links as necessary. By incorporating this feature directly into the product variation settings, I ensure efficient management and accurate association of webpage links with specific product variations.</p><p>Email Template Modification:<br>Next, I modified the order confirmation email template to dynamically include the custom webpage link for variations where it’s available. This enhancement ensures that customers receive relevant links tailored to their purchased items directly in the order confirmation emails. Here’s how I modified the email template:</p><pre>&lt;?php <br>// Get the order ID<br>$order_id = $order-&gt;get_id();<br><br>// Loop through order items<br>foreach ( $order-&gt;get_items() as $item_id =&gt; $item ) {<br>    // Get variation ID<br>    $variation_id = $item-&gt;get_variation_id();<br><br>    // Get custom online test link for the variation<br>    $online_test_link = get_post_meta( $variation_id, &#39;_online_test_link&#39;, true );<br><br>    // Check if the online test link exists<br>    if ( ! empty( $online_test_link ) ) {<br>?&gt;<br>&lt;p&gt;Thank you for your order. You can access the online test using the following link:&lt;/p&gt;<br>&lt;p&gt;&lt;?php echo esc_url(https://medium.com/$online_test_link); ?&gt;&lt;/p&gt;<br>&lt;?php <br>    }<br>}<br>?&gt;</pre><p>Conclusion:<br>By incorporating this feature, I’m able to offer customers valuable resources that enhance their overall post-purchase experience on my platform. This technical enhancement underscores my commitment to continually improving and personalizing the customer journey within my WooCommerce ecosystem.</p><p>As a WordPress developer, I’m proud to have played a role in implementing this feature, and I’m excited about the positive impact it will have on the customers’ experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d927267c48eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Musings on Web Design: Beyond the Bling]]></title>
            <link>https://medium.com/@eldritchchris/musings-on-web-design-beyond-the-bling-725889867a75?source=rss-60b2c28ca03e------2</link>
            <guid isPermaLink="false">https://medium.com/p/725889867a75</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ux-design]]></category>
            <category><![CDATA[ui-design]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[creativity]]></category>
            <dc:creator><![CDATA[Chris Kelechukwu]]></dc:creator>
            <pubDate>Sat, 13 Apr 2024 12:08:10 GMT</pubDate>
            <atom:updated>2024-04-13T12:08:10.930Z</atom:updated>
            <content:encoded><![CDATA[<p>Musings on Web Design: Beyond the Bling</p><p>Let&#39;s be honest, the internet is full of websites that prioritize flash over function. We&#39;ve all been there, bombarded by blinding color schemes, fancy buttons that go nowhere, and fonts that make you squint. While aesthetics are important, there&#39;s a whole other side to web design that often gets overlooked.</p><p>Today&#39;s musing dives into what truly makes a website stand out. It&#39;s not just about looking good (although that doesn&#39;t hurt!). Here&#39;s what gets me fired up about web design:</p><p>1. Market Magic: A website should be like a chameleon, seamlessly blending into its target audience’s environment. Imagine a design that speaks directly to your ideal customer, using visuals and language that resonate with their needs and desires. That’s the kind of market fit that makes a website truly sing.</p><p>2. The Power of UX: Have you ever gotten lost in a website labyrinth, desperately searching for that elusive &quot;contact us&quot; page? A smooth user experience (UX) is like an invisible map, guiding visitors effortlessly through your website. It’s about anticipating their needs and making navigation intuitive, keeping them engaged and moving towards your goals.</p><p>3. Conversion Chameleon: A website shouldn’t just be a pretty face. It should be a conversion machine, subtly guiding visitors towards taking action. This could be anything from making a purchase to signing up for your email list. Through strategic design elements and clear, compelling copywriting, a website can become a powerful tool for achieving your business objectives.</p><p>The Bling Brigade vs. Substantive Design</p><p>Some folks might think web design boils down to a checklist: having a website, making it responsive, throwing in some fancy fonts and buttons, and maybe even using some eye-searing colors. Let&#39;s call this the &quot;Bling Brigade&quot; approach. Sure, it covers the basics, but it misses the mark entirely.</p><p>A website built on this philosophy might look superficially flashy, but it fails to truly connect with its audience or achieve its goals. It&#39;s the difference between a billboard and a conversation.</p><p>Real web design is about understanding your audience, creating a seamless user experience, and crafting a website that converts. It’s about using design and copywriting strategically to achieve your business objectives.</p><p>So, what’s the takeaway?</p><p>Web design is more than just surface aesthetics. It&#39;s about understanding your audience, crafting a user-friendly experience, and ultimately, driving results. Let&#39;s celebrate websites that don&#39;t just look good, but strategically convert visitors into loyal customers.</p><p>This is just a spark of my thoughts on web design. What are your experiences with websites? What makes a website stand out for you? Share your thoughts in the comments below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=725889867a75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Abuja WordPress Architect: My Hustle is Real]]></title>
            <link>https://medium.com/@eldritchchris/the-abuja-wordpress-architect-my-hustle-is-real-d606ce722992?source=rss-60b2c28ca03e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d606ce722992</guid>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[work-life-balance]]></category>
            <category><![CDATA[work]]></category>
            <dc:creator><![CDATA[Chris Kelechukwu]]></dc:creator>
            <pubDate>Sat, 13 Apr 2024 08:23:25 GMT</pubDate>
            <atom:updated>2025-02-24T11:23:11.871Z</atom:updated>
            <content:encoded><![CDATA[<p>The Abuja WordPress Architect: My Hustle is Real</p><p>Forget the image of developers hunched over screens in air-conditioned bubbles. My day in Abuja is a vibrant mix of tasks, a digital architect wielding the power of WordPress. I translate user-friendly experiences into custom code, crafting websites that are both stunning and blazing fast, each one unique to my client’s vision.</p><p>One minute I might be explaining the SEO game to Joseph, like boosting a mama selling Akara at Wuse market to the top of the online search results. The next, I’m diving into the website itself, a digital sculptor chiseling away at lines of code to eliminate glitches and optimize performance for a smooth user journey.</p><p>My desk reflects this organized chaos. Notes sprawl across the surface like karmo market after a busy Tuesday, peppered with code snippets (think miniature instructions for the website) and with manga on the my secondary monitor for a mental break during the afternoon heat. The occasional raised eyebrow from my Oga (come on, we’ve all seen it) is usually followed by the inquiry, &quot;Project update?&quot; – a question that sends a jolt through me, a reminder of the multitude of tasks I’ve juggled in a single afternoon, like a skilled Keke driver navigating Abuja traffic.</p><p>Here&#39;s the thing, my brain works best in short, intense bursts of focus. Too much information overload at once? My productivity plummets faster than a data bundle during Sallah celebrations. That&#39;s why I conquer projects in focused sprints. Need help with website ranking? I&#39;ll open a specific browser tab, research best practices with laser focus like a hunter stalking prey on the plains, and close it promptly upon completion. It&#39;s my way of staying on track and avoiding the information overload that plagues the digital age, as real as the Abuja afternoon sun beating down on metal roofing.</p><p>And yes, those seemingly abandoned notes and half-written code snippets scattered across my desk? Not a sign of slacking off, but rather a testament to my &quot;all-or-nothing&quot; approach. When the focus hits, I dive headfirst into a task, be it crafting a custom plugin to supercharge website functionality, collaborating on design elements with colleagues like tailors working on a magnificent Aso Ebi, or even resolving a pesky computer issue that keeps popping up like unreliable Abuja electricity. This might leave a trail of brainstorming notes and discarded code attempts, the remnants of creative exploration, but for some developers like myself, it&#39;s the messy middle that leads to a surprisingly efficient outcome, much like the bustling marketplace that ultimately fosters a strong sense of community.</p><p>Don’t get me wrong, the structure and deadlines of my nine-to-five offer a welcome sense of accomplishment in a city that never sleeps. The paycheck is essential for keeping the fridge stocked, and the social interaction with colleagues, however brief, is a refreshing break, like sharing a cold bottle of Budweiser after a long day. But there’s a yearning within me, a desire for a space where my unique skillset can truly flourish.</p><p>Ideally, a space where quick breaks aren&#39;t seen as slacking off, but as a vital part of my process. A space where my bursts of energy and laser focus are recognized for what they are: the driving force behind my ability to craft beautiful, high-performing websites that go beyond the limitations of pre-built solutions.</p><p>Maybe one day, the stars will align, and I&#39;ll find that ideal work environment. But for now, I&#39;ll keep wielding my notepad and phone like secret weapons, turning stolen moments of focus into bursts of productivity, and hoping the websites I build continue to impress my clients. In the meantime, I&#39;ll embrace my unique approach and bridge the gap between the perception of a jack-of-all-trades and the reality of a well-oiled digital problem-solver, always ready for the next challenge, like a fearless entrepreneur venturing into a new market.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d606ce722992" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Freelancer to Full-Time: How My Freelance Hustle Makes Your WordPress Website a Conversion…]]></title>
            <link>https://medium.com/@eldritchchris/from-freelancer-to-full-time-how-my-freelance-hustle-makes-your-wordpress-website-a-conversion-37f520add57d?source=rss-60b2c28ca03e------2</link>
            <guid isPermaLink="false">https://medium.com/p/37f520add57d</guid>
            <category><![CDATA[wordpress-development]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[creativity]]></category>
            <dc:creator><![CDATA[Chris Kelechukwu]]></dc:creator>
            <pubDate>Sat, 13 Apr 2024 07:22:17 GMT</pubDate>
            <atom:updated>2024-04-13T07:22:17.600Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>From Freelancer to Full-Time: How My Freelance Hustle Makes Your WordPress Website a Conversion Champion</strong></p><p>Hey everyone, Chris Kelechukwu here! Ever switch careers and realize the skills you learned in the first gig make you a rockstar in the second? That&#39;s exactly what happened to me when I boomeranged back to a full-time WordPress development job after years of freelancing.</p><p>Sure, the nine-to-five routine is a bit different, but the core principles I honed as a freelancer haven&#39;t faded a bit. In fact, these principles are what set my work apart and allow me to build faster, more efficient, and conversion-focused WordPress websites for my clients.</p><p>Why Speed Matters: The Lean and Mean Website Advantage</p><p>One of my biggest priorities is building lean websites. This means using a minimal number of plugins and custom code to achieve the specific goals of each project. This approach offers a significant advantage: it leads to blazing-fast websites.</p><p>Think with Google studies (check this out: https://www.thinkwithgoogle.com/marketing-strategies/app-and-mobile/mobile-site-speed-tools-load-time/) show that a one-second delay in page load time can lead to a 7% reduction in conversions. In today&#39;s digital world, where every millisecond counts, this can have a major impact on your bottom line.</p><p>By keeping things lean, I ensure your website loads quickly and delivers a smooth user experience. This translates to happier visitors who are more likely to convert, ultimately boosting your sales and leads.</p><p>Unlocking WordPress&#39;s True Potential: The Power of Custom Code</p><p>The beauty of WordPress lies in its customizability. By leveraging custom code (HTML, CSS, JS, and PHP), along with WordPress hooks and custom fields, I can create unique and engaging experiences that go far beyond the core platform&#39;s capabilities. This applies to e-commerce as well!</p><p>With custom code, we can extend the functionalities of WooCommerce in powerful ways. Imagine adding features like:</p><p>Wholesale pricing to cater to your B2B clientele.<br>Selling individual items and bulk cartons with automatic pricing updates based on the customer&#39;s selection.<br>Streamlining the checkout process to minimize cart abandonment, a major pain point for online stores (OptinMonster study: https://optinmonster.com/ found a whopping 73% of online shop visitors abandon their carts!).<br>These are just a few examples of how custom coding can help you tackle specific challenges and create a website that converts visitors into loyal customers.</p><p>Many people underestimate the power of WordPress. It&#39;s a platform brimming with flexibility waiting to be unlocked. By embracing custom code, we can unleash its full potential and craft remarkable websites that not only look stunning but also drive results for your business.</p><p>The Freelancer Advantage: A Client-Centric Focus</p><p>My freelance experience instilled in me a deep understanding of client needs and a relentless focus on efficiency. These values translate perfectly into a full-time setting, shaping my approach to development every step of the way.</p><p>As a freelancer, I learned to prioritize the client&#39;s vision and goals above all else. This translates into building websites that are not just beautiful but also functional and achieve the specific results the client desires.</p><p>Now, working full-time, I bring this client-centric approach to every project. It allows me to collaborate effectively with clients and ensure their websites are not just fast and functional but also true conversion champions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37f520add57d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>