<?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 Sudhanshu Badole on Medium]]></title>
        <description><![CDATA[Stories by Sudhanshu Badole on Medium]]></description>
        <link>https://medium.com/@sudhanshubadole?source=rss-a20da751e0f1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rReAy_j2pX_wXm23CPLttA.jpeg</url>
            <title>Stories by Sudhanshu Badole on Medium</title>
            <link>https://medium.com/@sudhanshubadole?source=rss-a20da751e0f1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 04:15:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sudhanshubadole/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[Why Every Developer Should Take the CS50 Course]]></title>
            <link>https://medium.com/@sudhanshubadole/why-every-developer-should-take-the-cs50-course-fb11a27a3490?source=rss-a20da751e0f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb11a27a3490</guid>
            <category><![CDATA[harvard-university]]></category>
            <category><![CDATA[cs50]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Sudhanshu Badole]]></dc:creator>
            <pubDate>Sun, 11 Aug 2024 14:33:00 GMT</pubDate>
            <atom:updated>2024-08-11T14:33:00.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*15o6AycRNIZYgYkVCr6xyw.png" /></figure><p>In the ever-evolving world of software development, it’s easy to fall into the trap of thinking that once you’ve mastered a few programming languages, frameworks, and algorithms, you’ve reached the pinnacle of your craft. I used to believe that after solving over 1,000 coding problems and spending more than a year as a software engineer, I had little left to learn from traditional courses. Self-study, problem-solving, and project-building seemed like the best way to continue developing my skills. But a chance encounter with a fellow developer, who was light-years ahead in his problem-solving abilities and comfort with any language or framework, made me reconsider this approach.</p><p>This developer, whom I deeply admired for his technical prowess, attributed much of his success to a single course: CS50, the famous introductory computer science course offered by Harvard University and taught by the legendary David Malan. Initially, I was skeptical. What could a course designed for beginners offer someone with my experience? But as I continued to observe this colleague’s ability to get things done, even in unfamiliar territory, I grew curious. Could this course really be the key to unlocking the kind of expertise I aspired to?</p><p>Reluctantly, I decided to check it out. I typed “CS50” into YouTube, and what I found was nothing short of a revelation. The way David Malan explained complex concepts with such clarity and depth made me feel like a beginner again — in the best possible way. For the first time in my learning journey, I didn’t need to take notes. Everything Malan taught seemed to go straight to my core memory, reshaping my understanding of computer science and problem-solving.</p><p>The CS50 course isn’t just about learning to code; it’s about learning how to think like a programmer. It teaches you how to approach problems methodically, how to debug effectively, and most importantly, how to learn and adapt in an ever-changing field. These are the skills that set apart good programmers from great ones, and they are precisely what CS50 instills in its students.</p><p>For anyone, whether you’re just starting out or you’ve been in the field for years, I can’t recommend this course enough. It’s not just a course — it’s an experience that will transform the way you approach your work. After completing it, I found myself following David Malan on every platform, subscribing to the CS50 channels on YouTube, LinkedIn, and Twitter, and eagerly awaiting more content that could further enrich my skills.</p><p>In conclusion, if you’re serious about becoming a better programmer — someone who can tackle any challenge, regardless of the language or framework — then you owe it to yourself to take the CS50 course. It’s an investment of time that will pay dividends in your career, equipping you with the tools to not just code, but to excel.</p><p>**Your Turn to Level Up**</p><p>Whether you’re a fresher or an experienced developer, the CS50 course is a must. It will teach you not just how to code, but how to be a better programmer, thinker, and problem-solver. Don’t just take my word for it — dive in and experience it for yourself. You might just find, as I did, that it changes everything.</p><p>#CS50 #Programming #SoftwareEngineering #ContinuousLearning #DeveloperJourney</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb11a27a3490" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Play Audio in Frappe Framework]]></title>
            <link>https://medium.com/@sudhanshubadole/play-audio-in-frappe-framework-db7e079a8cfe?source=rss-a20da751e0f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/db7e079a8cfe</guid>
            <category><![CDATA[frappe-framework]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[frappe]]></category>
            <category><![CDATA[erpnext]]></category>
            <dc:creator><![CDATA[Sudhanshu Badole]]></dc:creator>
            <pubDate>Sun, 31 Mar 2024 09:59:55 GMT</pubDate>
            <atom:updated>2024-04-04T17:57:19.548Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction:</strong></h3><p>Enhancing user experience in web development often involves integrating multimedia elements such as audio. When working with the Frappe framework, various methods can be employed to seamlessly incorporate audio functionalities. In this article, we’ll explore different approaches to audio playback within Frappe applications, addressing common challenges and providing effective solutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*VxmAMpguD19bkSXX79ZJRw.png" /><figcaption>Frappe Framework</figcaption></figure><h3>Using JavaScript Audio:</h3><p>One of the fundamental methods to play audio in Frappe is through JavaScript. Utilizing the ‘audio’ element in HTML combined with JavaScript enables dynamic audio playback. However, a common hurdle arises when attempting to play audio files dynamically on user interactions, such as button clicks.</p><p>Consider the scenario where audio needs to be played each time a button is clicked. Initially, one might use JavaScript to create an audio element and play the audio file. In JavaScript, dynamically creating audio elements and playing them is a common approach. Consider the following code snippet:</p><pre>function playAudio() {<br>    var audio = document.createElement(&#39;audio&#39;);<br>    audio.src = &#39;https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3&#39;;<br>    audio.play();<br>}</pre><p>However, a common hurdle arises when attempting to play audio files dynamically on user interactions, such as button clicks.</p><blockquote><strong>I was trying to load the audio file from my file system. This did’nt work, I had to pass a URL to the audio source.</strong></blockquote><p>Consider the scenario where audio needs to be played each time a button is clicked. Initially, one might use JavaScript to create an audio element and play the audio file. However, a drawback emerges wherein the browser caches the audio, resulting in the repetition of the previous audio on subsequent clicks.</p><p>To circumvent this issue, a simple yet effective solution involves appending a unique timestamp to the audio source URL. By adding a timestamp parameter, the browser treats each audio request as distinct, preventing caching-related playback issues. Here’s how you can implement this:</p><pre>function playAudio() {<br>    var audio = document.createElement(&#39;audio&#39;);<br>    var uniqueTimestamp = new Date().getTime();<br>    audio.src = &#39;https://www.learningcontainer.com/wp-content/uploads/2020/02/spe.mp3?timestamp=&#39; + uniqueTimestamp;<br>    audio.play();<br>}</pre><p>Dealing with Audio File URLs:</p><p>Obtaining the URL of the audio file within the Frappe application is crucial. If the audio file is stored locally, it’s advisable to upload it to the public folder and retrieve its URL dynamically. Here’s how you can achieve this:</p><pre>function playAudio() {<br>    var audio = document.createElement(&#39;audio&#39;);<br>    var uniqueTimestamp = new Date().getTime();<br>    const sitePath = frappe.urllib.get_base_url();<br>    audio.src = sitePath + &#39;/files/speech.mp3?timestamp=&#39; + uniqueTimestamp;<br>    audio.play();<br>}</pre><h3>Integrating Frappe Sound:</h3><p>Alternatively, Frappe provides a built-in utility, ‘frappe.utils.play_sound()’, specifically designed for audio playback within the framework. This method offers a seamless approach to play notification sounds or any other audio cues required in the application.</p><p>To utilize Frappe Sound, you need to ensure that the audio files are stored in the correct directory and configured appropriately in the backend. Here’s a step-by-step guide:</p><ol><li>Store the audio file(s) in the ‘/sites/assets’ folder of your Frappe application.</li><li>Define the audio settings in the ‘hooks.py’ file, specifying the name, source path, and volume level.</li><li>Invoke the ‘frappe.utils.play_sound()’ function in the JavaScript file whenever audio playback is required.</li></ol><p>Sample configuration in ‘hooks.py’:</p><pre>sounds = [<br>    {&quot;name&quot;: &quot;ping&quot;, &quot;src&quot;: &quot;/assets/app/sounds/speech.mp3&quot;, &quot;volume&quot;: 0.2}<br>]</pre><p>Usage in JavaScript file:</p><pre>frappe.utils.play_sound(&quot;ping&quot;);</pre><h3>Conclusion:</h3><p>Incorporating audio playback functionality within Frappe applications significantly enhances the overall user experience. By leveraging JavaScript audio elements or utilizing Frappe’s built-in sound utility, developers can seamlessly integrate audio cues into their applications. Whether it’s dynamic audio playback or notification sounds, understanding these methods empowers developers to create engaging and immersive web experiences with Frappe.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db7e079a8cfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Essential Git Commands for Collaborative Project Work]]></title>
            <link>https://medium.com/@sudhanshubadole/essential-git-commands-for-collaborative-project-work-e033a1771ee3?source=rss-a20da751e0f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e033a1771ee3</guid>
            <category><![CDATA[bitbucket]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Sudhanshu Badole]]></dc:creator>
            <pubDate>Sat, 17 Feb 2024 18:00:29 GMT</pubDate>
            <atom:updated>2024-02-17T18:00:29.262Z</atom:updated>
            <content:encoded><![CDATA[<p>Git is a powerful version control system that is widely used in collaborative software development projects. When working in a team, it’s crucial to understand and utilize essential Git commands to effectively manage code changes, collaborate with team members, and ensure project integrity. In this article, we’ll discuss some of the most commonly used Git commands for teamwork, along with examples illustrating their usage.</p><ol><li>git status: This command provides information about the current state of the working directory and staging area. It shows which files have been modified, added, or deleted since the last commit.</li></ol><p>Example:</p><pre>git status</pre><ol><li>git branch: Lists all the local branches in the repository. Branches are useful for parallel development and isolating changes.</li></ol><p>Example:</p><pre>git branch</pre><ol><li>git checkout: Allows you to switch between branches or restore files from a specific commit.</li></ol><p>Example:</p><pre>git checkout &lt;branch_name&gt;</pre><ol><li>git checkout -b &lt;branch_name&gt;: Creates a new branch and switches to it in one step.</li></ol><p>Example:</p><pre>git checkout -b feature/new-feature</pre><ol><li>git add .: Adds all modified files in the working directory to the staging area in preparation for committing.</li></ol><p>Example:</p><pre>git add .</pre><ol><li>git commit -m “commit message”: Commits staged changes to the repository with a descriptive message.</li></ol><p>Example:</p><pre>git commit -m &quot;Added login functionality&quot;</pre><ol><li>git pull: Fetches changes from a remote repository and integrates them into the local branch.</li></ol><p>Example:</p><pre>git pull origin main</pre><ol><li>git push: Uploads local branch commits to a remote repository.</li></ol><p>Example:</p><pre>git push origin feature/new-feature</pre><ol><li>git push upstream &lt;branch_name&gt;: Pushes local changes to a branch in the upstream repository (commonly used for code reviews).</li></ol><p>Example:</p><pre>git push upstream feature/new-feature</pre><ol><li>git remote add &lt;name&gt; &lt;url&gt;: Adds a new remote repository to the local Git configuration.</li></ol><p>Example:</p><pre>git remote add upstream &lt;upstream_repo_url&gt;</pre><ol><li>git pull — rebase false: Performs a pull from the remote repository without rebasing.</li></ol><p>Example:</p><pre>git pull --rebase false</pre><ol><li>git log: Displays a chronological list of commits in the repository.</li></ol><p>Example:</p><pre>git log</pre><ol><li>git revert: Creates a new commit that undoes the changes made by a previous commit.</li></ol><p>Example:</p><pre>git revert &lt;commit_sha&gt;</pre><p>Explanation:</p><ul><li>Remote: A remote is a repository hosted on a server where team members can collaborate. It allows users to fetch and push changes to and from the repository.</li><li>Origin: “Origin” is the default name for the remote repository from which the local repository was cloned. It is often used to refer to the main repository where all team members contribute changes.</li><li>Upstream: “Upstream” typically refers to the original repository from which the fork (a copy of the repository) was made. It’s commonly used when collaborating on open-source projects, where contributors fork the original repository, make changes, and then submit pull requests to the upstream repository for review and integration.</li></ul><p>What to do if you did a wrong push: If you accidentally push changes to the wrong branch or repository, you can use the following steps to rectify the mistake:</p><ol><li>Undo the wrong push by reverting the commit(s) that introduced the unwanted changes.</li><li>Push the corrected changes to the appropriate branch or repository.</li><li>Communicate with your team members to ensure everyone is aware of the mistake and the corrective actions taken.</li></ol><p>By following these steps, you can rectify the wrong push and maintain the integrity of the project’s codebase.</p><p>Conclusion:</p><p>These essential Git commands are indispensable for collaborating effectively on software development projects. By mastering these commands and understanding their usage, team members can streamline their workflow, manage code changes efficiently, and ensure project success.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e033a1771ee3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplifying Child Table Operations in Frappe ERPNext: A Shopping Cart and Wishlist Example]]></title>
            <link>https://medium.com/@sudhanshubadole/simplifying-child-table-operations-in-frappe-erpnext-a-shopping-cart-and-wishlist-example-d88efbdb08eb?source=rss-a20da751e0f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d88efbdb08eb</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[erp]]></category>
            <category><![CDATA[frappe-framework]]></category>
            <category><![CDATA[frappe]]></category>
            <category><![CDATA[erpnext]]></category>
            <dc:creator><![CDATA[Sudhanshu Badole]]></dc:creator>
            <pubDate>Sun, 28 Jan 2024 04:29:04 GMT</pubDate>
            <atom:updated>2024-01-28T04:29:04.796Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:</strong></p><p>Child tables, a fundamental component within the Frappe framework, play a pivotal role in data management. They allow developers to organize and maintain structured relationships between different entities, enhancing the overall flexibility and extensibility of data models. Understanding the significance of child tables is crucial for developers to harness the full potential of Frappe ERPNext and create customized solutions tailored to specific business requirements.</p><p>As we delve into the intricacies of Frappe ERPNext, this article aims to shed light on the importance of child tables and guide developers through practical examples, focusing on a common use case — managing a shopping cart and wishlist. By the end of this exploration, developers will gain insights into streamlining child table operations, ultimately making their Frappe ERPNext development experience more efficient and effective.</p><p><strong>Common Challenges in Child Table Management:</strong></p><ol><li>Complex Operations: Developers often grapple with the complexity of performing operations, such as addition, deletion, or modification, on child table records due to their nested structure.</li><li>Data Retrieval: Efficiently retrieving specific data from child tables while maintaining data integrity poses a challenge, especially when dealing with large datasets.</li><li>Consistency and Validation: Ensuring data consistency and implementing validation logic across child tables requires careful consideration to prevent data inconsistencies or errors.</li><li>User Permissions: Managing user permissions for child table operations can be intricate, as developers need to strike a balance between restricting unauthorized access and facilitating necessary actions.</li><li>Optimizing Query Performance: Optimizing queries involving child tables to maintain system performance becomes essential, particularly when dealing with complex data relationships.</li></ol><p>Addressing these challenges is crucial for developers to create robust and reliable applications within the Frappe ERPNext framework.</p><p><strong>Example Use Case: Shopping Cart and Wishlist:</strong></p><p>Introduce the Scenario: Creating a Shopping Cart and Wishlist</p><p>In our example, we are addressing the practical needs of an e-commerce application by implementing a Shopping Cart and Wishlist functionality within the Frappe ERPNext framework. This scenario is a common requirement for businesses looking to enhance the user experience and streamline the purchasing process for their customers.</p><p>Structure of the Example:</p><p>To illustrate this concept, we have designed a structured data model with three primary components:</p><ol><li>User Doctype:</li></ol><ul><li>Fields:</li><li>User ID: A link field connecting to the standard Frappe ERPNext User doctype. This establishes a relationship between the user and their associated shopping cart and wishlist.</li></ul><p>2. Shopping Cart Doctype:</p><ul><li>Fields:</li><li>User ID: A link field establishing a connection to the User doctype, indicating the user associated with the shopping cart.</li><li>Shopping List: A link field connecting to the Shopping Cart Table doctype. This field serves as a reference to the child table containing details of products added to the shopping cart.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nRCq_WTXkM4Xv787wBiXKw.png" /><figcaption>Doctype: Shopping Cart</figcaption></figure><p>3. Shopping Cart Table Doctype (Child Table):</p><ul><li>Fields:</li></ul><ol><li>Product ID: A link field (type: Link) representing the unique identifier for each product added to the shopping cart.</li><li>Product Name: A data field (type: Data) storing the name of the product.</li><li>Price: An integer field (type: Int) capturing the unit price of the product.</li><li>Quantity: An integer field (type: Int) indicating the quantity of the product in the shopping cart.</li><li>Subtotal: An integer field (type: Int) calculating the subtotal for each product based on its quantity and price.</li><li>Image: An attach image field (type: Attach Image) allowing the inclusion of product images for reference.</li></ol><p>I have Fetch all values using Product ID which is link to Item</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tZ6xNUVJfC9KbRAkxjhP7g.png" /><figcaption>Doctype: Shopping Cart Table (Child Table)</figcaption></figure><p>Same for Wishlist</p><p>Wishlist Table (Child Table — Wishlist Table):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z76l3YseXdqBvtItVezZtQ.png" /></figure><p>Jollys Wishlist (Parent Doctype):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*981DEmV2jScXTthlXHoNkg.png" /></figure><h3>Adding Products to Wishlist:</h3><p>In this section, we’ll explore how to add products to the wishlist in the Frappe ERPNext framework. The provided code snippet demonstrates a practical implementation of this process. Let’s break down the key components:</p><h4>Code Implementation:</h4><pre>@frappe.whitelist(allow_guest=True)<br>def add_product_to_wishlist(user_id, item_id):<br>    # user_id = &#39;sam@gmail.com&#39;<br>    # item_id = &#39;0011&#39;<br>    # user_id  =frappe.session.user<br>    user = frappe.get_all(&quot;User&quot;, filters={&#39;email&#39;: user_id})<br>    user_wishlist = frappe.get_all(&quot;Jollys Wishlist&quot;, filters={&#39;user_id&#39;: user_id})<br>    <br>    # Create a new wishlist if it doesn&#39;t exist for the user<br>    if user and not user_wishlist:<br>        wishlist_doc = frappe.new_doc(&quot;Jollys Wishlist&quot;)<br>        wishlist_doc.user_id = user_id<br>        wishlist_doc.save(ignore_permissions=True)<br>    <br>    try:<br>        # Retrieve the existing wishlist for the user<br>        wishlist = frappe.get_doc(&#39;Jollys Wishlist&#39;, user_id)<br>        # Check if the product is already in the wishlist<br>        for item in wishlist.wishlist:<br>            if item.product_id == item_id:<br>                return &quot;Product already exists in the wishlist!&quot;<br>            <br>        # Create a new product entry in the wishlist<br>        new_product = frappe.get_doc({<br>            &#39;doctype&#39;: &#39;Wishlist Table&#39;,      # Child Doctype Name<br>            &#39;parent&#39;: wishlist.name,          # Parent record name<br>            &#39;parentfield&#39;: &#39;wishlist&#39;,        # Field name for the child table<br>            &#39;parenttype&#39;: &#39;Jollys Wishlist&#39;,  # Parent name<br>            &#39;product_id&#39;: item_id,            # ID of the item from Item DocType<br>        })<br>        new_product.insert(ignore_permissions=True)<br>        return &quot;Product added successfully to the wishlist cart!&quot;<br>    except frappe.DoesNotExistError:<br>        return f&quot;Jollys Wishlist for user ID {user_id} not found.&quot;<br>    except Exception as e:<br>        return f&quot;An error occurred: {str(e)}&quot;</pre><h4>Explanation:</h4><ol><li>Decorators and Function Definition:</li></ol><ul><li>The @frappe.whitelist(allow_guest=True) decorator enables the function to be called via API, allowing guest access.</li></ul><p>2. User and Wishlist Validation:</p><ul><li>Validate the existence of the user and check if a wishlist already exists for the user. Create a new wishlist if not.</li></ul><p>3. Retrieve Wishlist and Check Existing Products:</p><ul><li>Use frappe.get_doc to retrieve the existing wishlist for the user.</li><li>Check if the product is already in the wishlist by iterating through existing entries.</li></ul><p>4. Add New Product to Wishlist:</p><ul><li>Create a new product entry using frappe.get_doc and insert it into the wishlist&#39;s child table.</li></ul><p>5. Error Handling:</p><ul><li>Handle the case where the wishlist for the user is not found using frappe.DoesNotExistError.</li><li>Catch any other exceptions and return an appropriate error message.</li></ul><p>This code snippet showcases the efficient use of Frappe API methods (frappe.new_doc and doc.insert) for adding products to the wishlist, along with comprehensive error handling to ensure a smooth user experience.</p><h3><strong>Viewing Wishlist Items:</strong></h3><p>To enable users to view the items in their wishlist, we’ll create a whitelisted function that retrieves and displays wishlist items. The code snippet below demonstrates how to achieve this in Frappe ERPNext:</p><pre>@frappe.whitelist(allow_guest=True)<br>def get_items_from_wishlist(user_id):<br>    try:<br>        # Fetch the Wishlist record based on user_id<br>        wishlist = frappe.get_doc(&#39;Jollys Wishlist&#39;, {&#39;user_id&#39;: user_id})<br>        items_info = []<br>        # Iterate through each item in the wishlist child table<br>        for item in wishlist.wishlist:<br>            item_details = {<br>                &#39;product_id&#39;: item.product_id,<br>                &#39;product&#39;: item.product,  # Field name for product name<br>                &#39;price&#39;: item.price,  # Field name for price<br>                &#39;stock_status&#39;: item.stock_status,<br>                &#39;image&#39;: item.image<br>            }<br>            items_info.append(item_details)<br>        # Return the list of item details<br>        return items_info<br>    except frappe.DoesNotExistError:<br>        return f&quot;Wishlist for user ID {user_id} not found.&quot;<br>    except Exception as e:<br>        return f&quot;An error occurred: {str(e)}&quot;</pre><p>Explanation of the code:</p><ol><li>The function get_items_from_wishlist is whitelisted to allow guest access, making it accessible via API calls.</li><li>The code uses frappe.get_doc to fetch the Wishlist record based on the provided user_id.</li><li>It initializes an empty list items_info to store information about each wishlist item.</li><li>The function iterates through each item in the wishlist child table and extracts relevant details such as product_id, product (product name), price, stock_status, and image.</li><li>The details for each item are added to the items_info list.</li><li>The function returns the list of item details, allowing users or applications to retrieve and display the wishlist items.</li><li>Proper error handling is implemented to manage cases where the wishlist is not found or if any other exceptions occur during the process.</li></ol><p>By providing this functionality, users can easily view the contents of their wishlist, enhancing the overall user experience in your Frappe ERPNext application.</p><h3>Removing Products from Wishlist:</h3><p>In this section, we’ll dive into the process of deleting a product from the wishlist and ensure a smooth user experience. The following code snippet demonstrates how to implement this functionality:</p><pre>@frappe.whitelist(allow_guest=True)<br>def delete_product_from_wishlist_cart(user_id, item_id):<br>    try:<br>        # Retrieve the Wishlist document for the specified user<br>        wishlist_cart = frappe.get_doc(&#39;Jollys Wishlist&#39;, user_id)<br>        # Check for unauthorized access<br>        if wishlist_cart.user_id != user_id:  <br>            return &quot;Unauthorized access to modify this shopping cart.&quot;<br>        # Iterate through wishlist items to find the target product<br>        for item in wishlist_cart.wishlist:<br>            if item.product_id == item_id:<br>                # Remove the item from the wishlist<br>                wishlist_cart.remove(item)<br>                wishlist_cart.save()<br>                return f&quot;Item with ID {item_id} removed from the Jollys Wishlist successfully.&quot;<br>        # Notify if the item is not found in the wishlist<br>        return f&quot;Item with ID {item_id} not found in the Jollys Wishlist.&quot;<br>    except frappe.DoesNotExistError:<br>        # Handle the case where the wishlist for the specified user is not found<br>        return f&quot;Wishlist Cart with ID {user_id} not found.&quot;<br>    except Exception as e:<br>        # Handle unexpected errors<br>        return f&quot;An error occurred: {str(e)}&quot;</pre><p>Explanation:</p><ol><li>Retrieve Wishlist Document: We use frappe.get_doc to retrieve the Wishlist document based on the user_id provided.</li><li>Check for Unauthorized Access: Verify that the user making the request has the appropriate permissions to modify their own wishlist.</li><li>Iterate Through Wishlist Items: Loop through the wishlist items to find the target product by comparing product IDs.</li><li>Remove and Save: If the target product is found, remove it from the wishlist, save the document, and provide a success message.</li><li>Handle Item Not Found: If the item is not found in the wishlist, notify the user.</li><li>Handle Exceptions: Utilize exception handling to address cases where the wishlist document or other unexpected errors occur. The appropriate error messages are returned to the user for clarity.</li></ol><h3>Moving Products from Wishlist to Shopping Cart:</h3><p>Explain the Need for Moving Items:</p><ul><li>Emphasize that the wishlist typically serves as a collection of desired products, while the shopping cart represents the products intended for purchase.</li></ul><pre>@frappe.whitelist(allow_guest=True)<br>def move_product_from_wishlist_to_cart(user_id, product_id):<br>    # Functionality to move a product from the wishlist to the shopping cart<br>    <br>    user_shopping_cart = frappe.get_all(&quot;Shopping Cart&quot;, filters={&#39;user_id&#39;: user_id})<br>    user = frappe.get_all(&quot;User&quot;, filters={&#39;email&#39;: user_id})<br>    if user and not user_shopping_cart:<br>        shopping_cart_doc = frappe.new_doc(&quot;Shopping Cart&quot;)<br>        shopping_cart_doc.user_id = user_id<br>        shopping_cart_doc.save(ignore_permissions=True)<br>    try:<br>        wishlist = frappe.get_doc(&#39;Jollys Wishlist&#39;, {&#39;user_id&#39;: user_id})<br>        shopping_cart = frappe.get_doc(&#39;Shopping Cart&#39;, {&#39;user_id&#39;: user_id})<br>        product_to_move = None<br>        for item in wishlist.wishlist:<br>            if item.product_id == product_id:<br>                product_to_move = item<br>                break<br>        if product_to_move:<br>            new_product = frappe.get_doc({<br>                &#39;doctype&#39;: &#39;Shopping Cart Table&#39;,  # Child Doctype Name<br>                &#39;parent&#39;: shopping_cart.name,  # Parent record name<br>                &#39;parentfield&#39;: &#39;shopping_list&#39;,  # Field name for the child table<br>                &#39;parenttype&#39;: &#39;Shopping Cart&#39;,  # Parent name<br>                &#39;product_id&#39;: product_to_move.product_id,  # ID of item from Item DocType<br>            })<br>            # Save the new Product List entry in Shopping Cart<br>            new_product.insert(ignore_permissions=True)<br>            shopping_cart = frappe.get_doc(&#39;Shopping Cart&#39;, user_id)<br>            shopping_cart.save()<br>            # Remove the product from the Wishlist<br>            wishlist.wishlist.remove(product_to_move)<br>            wishlist.save(ignore_permissions=True)<br>            return &quot;Product moved from Wishlist to Shopping Cart successfully!&quot;<br>        else:<br>            return f&quot;Product with ID {product_id} not found in the wishlist.&quot;<br>    except frappe.DoesNotExistError:<br>        return f&quot;Wishlist or Shopping Cart for user ID {user_id} not found.&quot;<br>    except Exception as e:<br>        return f&quot;An error occurred: {str(e)}&quot;</pre><h3>Updating the Quantity of an Item in the Shopping Cart:</h3><p>In addition to adding items to the shopping cart, it’s crucial to provide users with the ability to update the quantity of items already present. Here’s an example function for updating the quantity of a specific item in the shopping cart:</p><pre>@frappe.whitelist(allow_guest=True)<br>def update_cart_item_quantity(user_id, item_id, quantity):<br>    # user_id = &#39;jay@gmail.com&#39;<br>    # item_id = &#39;0014&#39;<br>    # quantity = 3<br>    try:<br>        # Fetch the Shopping Cart record based on user_id<br>        shopping_cart = frappe.get_doc(&#39;Shopping Cart&#39;, {&#39;user_id&#39;: user_id})<br>        # Iterate through each item in the shopping cart<br>        for item in shopping_cart.shopping_list:<br>            # Check if the current item matches the specified item_id<br>            if item.product_id == item_id:<br>                # Update the quantity of the item<br>                item.quantity = quantity<br>                # Save the changes to the shopping cart<br>                shopping_cart.save(ignore_permissions=True)<br>                # Provide a success message<br>                return f&quot;Quantity updated successfully for item {item_id} in the shopping cart!&quot;<br>        # If the specified item_id is not found in the shopping cart<br>        return f&quot;Item with ID {item_id} not found in the shopping cart.&quot;<br>    except frappe.DoesNotExistError:<br>        # If the shopping cart for the user is not found<br>        return f&quot;Shopping Cart for user ID {user_id} not found.&quot;<br>    except Exception as e:<br>        # Handle other exceptions that may occur<br>        return f&quot;An error occurred: {str(e)}&quot;</pre><p>In this code, the function takes the user_id, item_id, and the new quantity as parameters. It then retrieves the shopping cart for the specified user and iterates through each item in the shopping list. If it finds an item with the matching item_id, it updates the quantity and saves the changes to the shopping cart.</p><p><strong>NOTE: you manipulate the code according to your need and same code can also we used to add or delete from shopping cart.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rc5LI1sVEROrKHOZVcQ5Yw.png" /></figure><p><strong>Conclusion</strong>: In conclusion, this article aimed to simplify the complexities associated with working on child tables in Frappe ERPNext, focusing on a practical example involving a shopping cart and wishlist. The key takeaways include:</p><ol><li>Efficient Addition and Deletion: Developers can seamlessly add and remove products from the wishlist and shopping cart using the provided code snippets, showcasing the power of Frappe ERPNext’s API.</li><li>Smooth Transition between Child Tables: The article demonstrated a smooth transition of products from the wishlist to the shopping cart, facilitating a user-friendly e-commerce experience.</li><li>Error Handling and Permissions: Throughout the code examples, emphasis was placed on error handling and ensuring the appropriate permissions, enhancing the robustness and security of the implementation.</li><li>Updating Existing Records: The addition of updating existing records in the shopping cart table further expands the capabilities of managing dynamic user interactions within the application.</li></ol><p>By understanding and implementing these techniques, developers can streamline the development process, making it more intuitive and efficient when working with child tables in Frappe ERPNext.</p><p><strong>Reiterating the Goal</strong>: The primary goal of this article was to empower developers with the knowledge and tools needed to simplify child table operations in Frappe ERPNext. By providing practical examples and clear explanations, the aim was to demystify common challenges associated with child tables, making the development process more accessible and enjoyable.</p><p>As developers continue to explore Frappe ERPNext for their projects, incorporating the discussed strategies can significantly enhance their ability to design dynamic and user-friendly applications. Remember that the key to mastering any framework lies in practical application and continuous exploration. May your Frappe ERPNext endeavors be both rewarding and efficient!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d88efbdb08eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>