<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sales Igniter</title>
    <description>The latest articles on DEV Community by Sales Igniter (@salesigniter).</description>
    <link>https://dev.to/salesigniter</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F849930%2F84328803-acb8-4d7b-927b-aa0019380468.jpg</url>
      <title>DEV Community: Sales Igniter</title>
      <link>https://dev.to/salesigniter</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/salesigniter"/>
    <language>en</language>
    <item>
      <title>Multi Vendor Inventory and Rental Bookings in Magento 2</title>
      <dc:creator>Sales Igniter</dc:creator>
      <pubDate>Tue, 19 Apr 2022 09:16:23 +0000</pubDate>
      <link>https://dev.to/salesigniter/multi-vendor-inventory-and-rental-bookings-in-magento-2-4k0g</link>
      <guid>https://dev.to/salesigniter/multi-vendor-inventory-and-rental-bookings-in-magento-2-4k0g</guid>
      <description>&lt;h3&gt;
  
  
  What Multi Location Inventory Features Are Available in Magento
&lt;/h3&gt;

&lt;p&gt;If you are comparing Magento 2 vs other open source shopping carts there really is no comparison if you need to have Multi Location or Multi Store features. The reason being that the next closest competitor WooCommerce does not have any sort of multi location or multi store feature built in. While WordPress does have multi site, this is not really feasible for WooCommerce multi store features for a number of reasons such as that it doesn't support store by store or location by location inventory syncing, it can't set product pricing by store, and the plugins that do exist for this cost extra nd since there is no standard for it you'll have issues if you ever want to integrate "plugins on top of plugins" as far as multi inventory is concerned. For a full breakdown of &lt;a href="https://rentalbookingsoftware.com/multi-source-inventory-warehouses-and-multi-store-magento-2-vs-woocommerce/"&gt;WooCommerce vs Magento 2 when it comes to multi store and multi inventory&lt;/a&gt; please check out our article. &lt;/p&gt;

&lt;h3&gt;
  
  
  How To Integrate Multi Location with Rentals
&lt;/h3&gt;

&lt;p&gt;First you'll need to make a reservations table, and in this reservations table you'll want as a minimum to have the start date, end date, order item id, order id, and inventory source. &lt;/p&gt;

&lt;p&gt;Here is what this would look like in your etc/db_schema.xml file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;table name="sirental_reservationorders" resource="default" engine="innodb" comment="sirental_reservationorders"&amp;gt;
    &amp;lt;column xsi:type="int" name="reservationorder_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Reservationorder_id"/&amp;gt;
    &amp;lt;column xsi:type="int" name="order_id" padding="10" unsigned="true" nullable="false" identity="false" default="0"/&amp;gt;
    &amp;lt;column xsi:type="int" name="product_id" padding="11" unsigned="false" nullable="false" identity="false" comment="Product_id"/&amp;gt;
    &amp;lt;column xsi:type="int" name="qty" padding="11" unsigned="false" nullable="false" identity="false" comment="Qty"/&amp;gt;
    &amp;lt;column xsi:type="int" name="qty_cancel" padding="11" unsigned="false" nullable="false" identity="false" default="0" comment="Cancelled Quantity"/&amp;gt;
    &amp;lt;column xsi:type="int" name="order_item_id" padding="11" unsigned="false" nullable="true" identity="false" comment="Order_item_id"/&amp;gt;
    &amp;lt;column xsi:type="datetime" name="start_date" on_update="false" nullable="true" comment="Start_date"/&amp;gt;
    &amp;lt;column xsi:type="datetime" name="end_date" on_update="false" nullable="true" comment="End_date"/&amp;gt;
    &amp;lt;column  name="source_code"  comment="Inventory Source Code" xsi:type="text"/&amp;gt;
  &amp;lt;/table&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that create the model, resourcemodel, and collection for this table. We recommend the &lt;a href="https://mage2gen.com/"&gt;https://mage2gen.com/&lt;/a&gt; for generating the base code for that, and then customizing it after. &lt;/p&gt;

&lt;p&gt;Finally you'll want to create a async style processor once the order is placed. Please checkout the official document for how to make &lt;a href="https://devdocs.magento.com/guides/v2.4/extension-dev-guide/async-operations.html"&gt;async calls&lt;/a&gt;. Or you could also make this as a cron that runs periodicall to process the rental orders. Here is a sample using the cron method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public function updateIsReserved()
    {
        if ($this-&amp;gt;stock-&amp;gt;reserveInventoryWithoutOrderInvoiced()) {

            $this-&amp;gt;searchCriteriaBuilder-&amp;gt;addFilter('is_reserved', 0);
            $criteria = $this-&amp;gt;searchCriteriaBuilder-&amp;gt;create();
            $Orders = $this-&amp;gt;orderRepository-&amp;gt;getList($criteria)-&amp;gt;getItems();

            foreach ($Orders as $order) {
                $this-&amp;gt;emulation-&amp;gt;startEnvironmentEmulation($order-&amp;gt;getStoreId(), 'frontend');
                $this-&amp;gt;stockManagement-&amp;gt;reserveQuoteOrOrder($order);
                $order-&amp;gt;setIsReserved(1);
                $order-&amp;gt;save();
                $this-&amp;gt;emulation-&amp;gt;stopEnvironmentEmulation();
            }
        }
    }

    public function execute()
    {
        $this-&amp;gt;updateIsReserved();
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Integrating Multi Vendor with Multi Location Inventory and Rental Inventory
&lt;/h3&gt;

&lt;p&gt;This involves making sure the admin rental inventory report is compatible with vendors, and that the vendors can only see their products. &lt;/p&gt;

&lt;h4&gt;
  
  
  Multi Vendor Commission Payouts
&lt;/h4&gt;

&lt;p&gt;Vendors will usually be paid out using Stripe or Paypal, but the method can vary for how you pay them. The main methods are: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pay based on a percentage of the order that is placed&lt;/li&gt;
&lt;li&gt;Vendor pays a membership fee to list products on your web site&lt;/li&gt;
&lt;li&gt;No payment, rather the site is monetized via advertising&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Adding Rental Order Notes Based On The Vendor ID
&lt;/h3&gt;

&lt;p&gt;This can be accomplished by using an Observer setup like this. First make a file at etc/events.xml with this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0"?&amp;gt;
&amp;lt;config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"&amp;gt;
    &amp;lt;event name="sales_order_place_after"&amp;gt;
    &amp;lt;observer name="purchaseorder_place_order_after" instance="SalesIgniter\Purchaserentals\Observer\PurchaseRentalsComment" /&amp;gt;
&amp;lt;/config&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then in the Model/Observer/PurchaseRentalsComment.php file you would have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $order = $observer-&amp;gt;getEvent()-&amp;gt;getOrder();
        $orderitems = $order-&amp;gt;getItems();
        foreach($orderitems as $item) {
            if ($item-&amp;gt;getParentItem()) {
                $originalBuyRequest = $item-&amp;gt;getParentItem()-&amp;gt;getBuyRequest();
            } else {
                $originalBuyRequest = $item-&amp;gt;getBuyRequest();
            }
            if($originalBuyRequest-&amp;gt;getPurchaseRentals() != null){
                $originalOrder = $this-&amp;gt;orderRepository-&amp;gt;get($originalBuyRequest-&amp;gt;getOriginalOrderid());
                $orignalOrderInc = $originalOrder-&amp;gt;getIncrementId();
                $order-&amp;gt;addCommentToStatusHistory('Rental Purchase for Order #: ' . $orignalOrderInc, $status = false, $isVisibleOnFront = true)-&amp;gt;setIsCustomerNotified(false);
                break;
            }
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Preventing Deducting Inventory for Rentals
&lt;/h3&gt;

&lt;p&gt;Since rentals are returned, you'll want to make sure that Magento 2 does not deduct inventory when orders are placed. You'll need to calculate your inventory instead using an inventory array built from the start and end dates. Here's how to prevent inventory deductions. Make a file at etc/di.xml and add this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;type name="Magento\InventorySourceDeductionApi\Model\SourceDeductionService"&amp;gt;
        &amp;lt;plugin name="prevent_source_deduction_for_rental" type="SalesIgniter\Rentalinventory\Plugin\InventorySourceDeductionApi\PreventStockDeductionForRentalPlugin" sortOrder="100"/&amp;gt;
    &amp;lt;/type&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the code for the actual plugin at Plugin/PreventAppendReservationForRentalPlugin.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public function aroundExecute(AppendReservationsInterface $subject, \Closure $proceed, array $reservations)
    {
        if (!$this-&amp;gt;stockConfiguration-&amp;gt;canSubtractQty()) {
            return;
        }

        $reservationToAppend = [];
        foreach ($reservations as $reservation) {
            $stockItemConfiguration = $this-&amp;gt;getStockItemConfiguration-&amp;gt;execute(
                $reservation-&amp;gt;getSku(),
                $reservation-&amp;gt;getStockId()
            );

            // don't add inventory reservations for rental products
            if(!$this-&amp;gt;rentalHelper-&amp;gt;isRentalTypeSimple($this-&amp;gt;productRepository-&amp;gt;get($reservation-&amp;gt;getSku()))){
                $reservationToAppend[] = $reservation;
            }
        }

        if (!empty($reservationToAppend)) {
            $proceed($reservationToAppend);
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Further Information
&lt;/h3&gt;

&lt;p&gt;For further information about &lt;a href="https://rentalbookingsoftware.com"&gt;multi vendor and multi store setups with rental bookings&lt;/a&gt; please visit our web site. &lt;/p&gt;

</description>
      <category>rental</category>
      <category>calendar</category>
      <category>magento2</category>
      <category>multivendor</category>
    </item>
    <item>
      <title>WooCommerce Bookings Plugin Development and Integration with Multi Vendor</title>
      <dc:creator>Sales Igniter</dc:creator>
      <pubDate>Tue, 19 Apr 2022 08:36:56 +0000</pubDate>
      <link>https://dev.to/salesigniter/integrating-rental-bookings-and-multi-vendor-for-woocommerce-2922</link>
      <guid>https://dev.to/salesigniter/integrating-rental-bookings-and-multi-vendor-for-woocommerce-2922</guid>
      <description>&lt;h3&gt;
  
  
  Choosing A Rental Bookings Plugin for WooCommerce
&lt;/h3&gt;

&lt;p&gt;There are many rental booking plugins available for WooCommerce. As a &lt;a href="https://rentalbookingsoftware.com/"&gt;developer of rental bookings systems&lt;/a&gt; for Magento 2, we had the benefit of using that experience and applying it towards WooCommerce. There is a huge difference between the two as far as their technology stack, but the basics remain the same. Some of the features we wanted to make sure to implement were: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Real rental inventory tracking, not just adding product attributes, but being able to query inventory for a given start and end date&lt;/li&gt;
&lt;li&gt;A flexible calendar that is well supported by the community, ideally it would support date ranges as well as times. We decided on Flatpickr.&lt;/li&gt;
&lt;li&gt;A day by day as well as hour by hour rental inventory report page&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Choosing A Multi Vendor Plugin for WooCommerce
&lt;/h3&gt;

&lt;p&gt;For the multi vendor portion we tested out a variety of different plugins for WooCommerce. What we found was that most of them to not support product bundles, and each has their own integration style. We settled upon Dokan because it had most of the features our client was looking for such as an integration with a WooCommerce auctions plugin, Stripe payouts, and the UI was nice to use. &lt;/p&gt;

&lt;h3&gt;
  
  
  Integrating Rentals Admin Pages with Dokan
&lt;/h3&gt;

&lt;p&gt;So the harder part comes to how do we integrate the Dokan Dashboard with our rental plugin admin reports? Not only that but we also wanted to integrate the processing of Advanced Custom Fields when a product is updated. Here's how we did it. First we needed to add these three filters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add_filter( 'dokan_get_dashboard_nav', [$this, 'add_booking_menu'] );
add_filter( 'dokan_query_var_filter', array( $this, 'add_dokan_booking_endpoint' ) );
add_action( 'dokan_load_custom_template', array( $this, 'load_booking_templates' ), 10, 1 );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(These are added in the init() method of our class, for class structure see below)&lt;/p&gt;

&lt;p&gt;Here are the methods for each of those:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; public function add_booking_menu($urls){
        $urls['bookinginventory1'] = [
                'title' =&amp;gt; __('Booking Inventory', 'sibooking'),
                'icon' =&amp;gt; '&amp;lt;i class="fa fa-truck"&amp;gt;&amp;lt;/i&amp;gt;',
                'url' =&amp;gt; dokan_get_navigation_url( 'sibooking/inventory'),
                'pos' =&amp;gt; 51,
                'permission' =&amp;gt; 'dokan_view_order_menu'
            ];
        $urls['bookingcalendar'] = [
            'title' =&amp;gt; __('Booking Calendar', 'sibooking'),
            'icon' =&amp;gt; '&amp;lt;i class="fa fa-calendar"&amp;gt;&amp;lt;/i&amp;gt;',
            'url' =&amp;gt; dokan_get_navigation_url( 'sibooking/calendar'),
            'pos' =&amp;gt; 51,
            'permission' =&amp;gt; 'dokan_view_order_menu'
            ];
        return $urls;
    }

    public function add_dokan_booking_endpoint($query_var){
        $query_var[] = 'sibooking';
        return $query_var;
    }

    public function load_booking_templates( $args ) {
        if ( isset( $args['sibooking'] )) {
            include(SIBOOKING_PLUGIN_ROOT . 'Templates/dokan/dashboard/calendar.php');
        }

    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that we added the templates to the folder: Templates/dokan/dashboard here is a sample of how that looks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php do_action( 'dokan_dashboard_wrap_start' ); ?&amp;gt;

&amp;lt;div class="dokan-dashboard-wrap"&amp;gt;

    &amp;lt;?php
    $current_page = get_query_var( 'sibooking' );
    /**
     *  dokan_dashboard_content_before hook
     *  dokan_dashboard_support_content_before
     *
     *  @hooked get_dashboard_side_navigation
     *
     *  @since 2.4
     */
    do_action( 'dokan_dashboard_content_before' );
    do_action( 'dokan_dashboard_support_content_before' );
    ?&amp;gt;

    &amp;lt;div class="dokan-dashboard-content dokan-booking-wrapper dokan-product-edit"&amp;gt;

&amp;lt;?php
switch ( $current_page ) {
    case 'calendar':
        echo do_shortcode('[vg_display_admin_page page_url="' . admin_url() . '?page=sibooking-calendar-report"]');
        break;
    case 'inventory':
        echo do_shortcode('[vg_display_admin_page page_url="' . admin_url() . '?page=sibooking-inventory-report"]');

        break;
}
?&amp;gt;
    &amp;lt;/div&amp;gt;&amp;lt;!-- .dokan-dashboard-content --&amp;gt;

    &amp;lt;?php

    /**
     *  dokan_dashboard_content_after hook
     *  dokan_dashboard_support_content_after hook
     *
     *  @since 2.4
     */
    do_action( 'dokan_dashboard_content_after' );
    do_action( 'dokan_dashboard_support_content_after' );
    ?&amp;gt;

&amp;lt;/div&amp;gt;&amp;lt;!-- .dokan-dashboard-wrap --&amp;gt;

&amp;lt;?php do_action( 'dokan_dashboard_wrap_end' ); ?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see in this code we are using the plugin WP Frontend on Admin for this. Here are the results: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--10UQL01Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9wmonf7ue9qnw266nptr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--10UQL01Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9wmonf7ue9qnw266nptr.jpg" alt="Rental Inventory Report" width="880" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  A Few Code Samples For Specific Parts of the Multi Vendor Rental System
&lt;/h3&gt;

&lt;p&gt;So we've gone over a bit of the Rental Bookings to Dokan multi vendor integration, but what about the rental calendar system itself, how does that work? Here are a few code samples: &lt;/p&gt;

&lt;h6&gt;
  
  
  Loading the Rental Calendar
&lt;/h6&gt;

&lt;p&gt;As you can see this is a action plugin for after the add to cart button is shown, it shows a custom template. That template has the code for loading the Flatpickr divs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add_action( 'woocommerce_before_add_to_cart_button', [$this, 'load_calendar'] );

    public function load_calendar() {
        if ( is_product() ) {
            if(sibooking_is_booking(wc_get_product()) == '1'){
                $template = '/single-product/add-to-cart/calendar.php';
                wc_get_template($template, $args = [], $template_path = '', dirname(__FILE__, 2) . '/Templates/');
            }
        }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How the rental calendar looks on the frontned, we of course also added the Flatpickr js and css files which we won't describe here, and wrote custom date range availability checks: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z3Ps5IC_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6jf9sletzmeibvm8tzth.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z3Ps5IC_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6jf9sletzmeibvm8tzth.jpg" alt="calendar front end" width="580" height="662"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Composer Loading
&lt;/h4&gt;

&lt;p&gt;We of course wanted to use Composer autoloading for our WooCommerce rental plugin. Here is how we accomplished that. Within the main entry point to the plugin we have the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
$libraries = require_once SIBOOKING_PLUGIN_ROOT . 'vendor/autoload.php';

add_action(
        'plugins_loaded', static function () use ( $libraries ) {
            // for phpunit to not throw error
            if(is_bool($libraries)){
                return;
            }
        new Sibookings($libraries);
    });

 public function __construct(\Composer\Autoload\ClassLoader $composer) {
        $this-&amp;gt;composer = $composer;
        $this-&amp;gt;version = SIBOOKING_VERSION;
        $this-&amp;gt;plugin_name = 'sibooking';
        $this-&amp;gt;set_locale();
        $this-&amp;gt;get_classes();
        $this-&amp;gt;init_classes();
    }

private function get_classes() {
        $prefix    = $this-&amp;gt;composer-&amp;gt;getPrefixesPsr4();
        $classmap  = $this-&amp;gt;composer-&amp;gt;getClassMap();
        $classes = \array_keys( $classmap );

        foreach ( $classes as $class ) {
            if ( strpos($class,'Sibooking') === FALSE ||
                strpos($class,'BookingDataObject') !== FALSE ||
                strpos($class,'BookingDataStore') !== FALSE ||
                strpos($class,'BookingEloquentModel') !== FALSE ||
                strpos($class,'BookingsTable') !== FALSE ||
                strpos($class,'BookingEloquentStore') !== FALSE ||
                strpos($class,'Utility') !== FALSE
            ) {
                continue;
            }
            $this-&amp;gt;classes[] = $class;
        }
        return $this-&amp;gt;classes;
    }

    private function init_classes() {
        foreach ( $this-&amp;gt;classes as $class ) {
            try {
                $temp = new $class;
                $temp-&amp;gt;init();
            } catch ( \Throwable $err ) {
                \do_action( 'sibooking_initialize_failed', $err );
                if ( WP_DEBUG ) {
                    throw new \Exception( $err-&amp;gt;getMessage() );
                }
            }
        }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method works really well as you can exclude certain classes that you don't want to load by using the strpo() area of the classes loop. &lt;/p&gt;

&lt;h4&gt;
  
  
  Class Structure
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Custom Rental Pricing
&lt;/h4&gt;

&lt;p&gt;Two hooks are needed to change to a custom rental price for rental products in WooCommerce. Here is the code for that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add_filter('woocommerce_product_get_price', [$this, 'set_rental_price_product'], 99, 2);
add_filter('woocommerce_add_cart_item', [$this,  'set_rental_price_cart'], 10, 2);

 /**
     * @param $price
     * @param \WC_Product $product
     * @return int|mixed|null
     */
    public function set_rental_price_product($price = null, $product = null) {
        $isbooking = sibooking_is_booking($product);
        $isbookingpurchase = !empty($product-&amp;gt;get_meta['_sibooking-isbookingpurchase']) ? true : false;
        if(!$isbooking || $isbookingpurchase == true){
            return $price;
        }

        $startDate = $product-&amp;gt;get_meta('sibooking-from');
        $endDate = $product-&amp;gt;get_meta('sibooking-to');

        if($startDate == '') {
            return $price;
        }

        $price = $this-&amp;gt;priceCalculation-&amp;gt;calculatePrice($product-&amp;gt;get_id(), $startDate, $endDate);

        return $price;
    }

 /**
     * @param $cart_item
     * @return int|mixed
     */
    public function set_rental_price_cart($cart_item, $cart_item_key) {
        $product = $cart_item['data'];
        $isbooking = sibooking_is_booking($product);
        $isbookingpurchase = !empty($cart_item['_sibooking-isbookingpurchase']) ? true : false;
        if(!$isbooking || $isbookingpurchase == true){
            return $cart_item;
        }

        $startDate = $cart_item['sibooking-from'];
        $endDate = $cart_item['sibooking-to'];

        $price = $this-&amp;gt;priceCalculation-&amp;gt;calculatePrice($product-&amp;gt;get_id(), $startDate, $endDate);

        $product-&amp;gt;set_price($price);

        $cart_item['data'] = $product;

        return $cart_item;
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Advanced Custom Fields for Rental Bookings
&lt;/h4&gt;

&lt;p&gt;Advanced Custom Fields Pro was used for building the rental bookings settings panel. We highly recommend using it especially with the repeator fields that are available and date time fields. &lt;/p&gt;

&lt;h3&gt;
  
  
  Multi Vendor WooCommerce Rental Booking Plugin
&lt;/h3&gt;

&lt;p&gt;For more information about our &lt;a href="https://rentalbookingsoftware.com"&gt;rental booking plugin for WooCommerce&lt;/a&gt; please visit our web site. &lt;/p&gt;

</description>
      <category>rental</category>
      <category>calendar</category>
      <category>woocommerce</category>
      <category>multivendor</category>
    </item>
  </channel>
</rss>
