maurosp91
Forum Replies Created
-
I finally found the cause and want to share it, so it might help others.
The issue was due to product addons module of dokan pro plugin.
add_action( ‘pre_get_posts’, [ $this, ‘render_vendor_global_addons’ ], 99 ); in class-frontend.php file.
The function render_vendor_global_addons() only checks for $_REQUEST[‘add-to-cart’]. However, when it is added via AJAX, “add-to-cart” becomes “product_id”. So get_posts() returns an empty array everytime.
And the randomness was because lite speed cache was fixing this issue most times. A downside of this was that the issue was very hard to identify and reproduce.
Hope it helps others.
Cheers!
Hi, I could achieve it. I share the code in case someone finds it helpful.
Firstly, I am using rehub theme. In which I modified 2 templates files in the child theme.
- rehub-theme -> dokan -> store.php
- rehub-theme -> inc -> parts -> woolistcompact.php (I’m using wholesale list as design of woo archive)
If your theme doesn’t modify the dokan single store page, you only need to modify this file: dokan-lite -> templates -> store.php
store.php: add these lines right before THE LOOP
<?php //I get the URL of the current page to compare it with the vendor URL page $protocol = "https://"; $CurPageURL = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>
woolistcompact.php: add these lines inside THE LOOP, right after checking if $product is not empty
<?php //if current URL page is same as vendor URL page, then show 1 item per category if ( $CurPageURL == $store_url) { //get the categories of the product in each loop $cat_ids = $product->get_category_ids(); //if there is only 1 category if ( count($cat_ids) == 1 ) { $cat_id = $cat_ids[0]; } //if there are 2 categories, I take the child one elseif ( count($cat_ids) == 2 ) { $parents1 = get_ancestors( $cat_ids[0], 'product_cat', 'taxonomy' ); $parents2 = get_ancestors( $cat_ids[1], 'product_cat', 'taxonomy' ); if ( count($parents1) > count($parents2) ) { $cat_id = $cat_ids[0]; } else { $cat_id = $cat_ids[1]; } } //if there are 3 categories, I take the grandchild one elseif ( count($cat_ids) == 3 ) { $parents1 = get_ancestors( $cat_ids[0], 'product_cat', 'taxonomy' ); $parents2 = get_ancestors( $cat_ids[1], 'product_cat', 'taxonomy' ); $parents3 = get_ancestors( $cat_ids[2], 'product_cat', 'taxonomy' ); if ( count($parents1) > count($parents2) ) { if ( count($parents1) > count($parents3) ) { $cat_id = $cat_ids[0]; } else { $cat_id = $cat_ids[2]; } } else { if ( count($parents2) > count($parents3) ) { $cat_id = $cat_ids[1]; } else { $cat_id = $cat_ids[2]; } } } //Get the category name $term = get_term_by( 'id', $cat_id, 'product_cat' ); $cat_name = $term->name; //Checking if another item of the same category was already shown if ( $categories[$cat_id] == 1 ) { //was shown return; } else { //wasn't shown - FLAG $categories[$cat_id] = 1; } } ?>
woolistcompact.php: add these lines right at the end of each loop
<?php //Adding the "See more" link //Only when this happens if ( $CurPageURL == $store_url ) { ?> <div class="woocommerce type-product woocompactlist mb10 mt10 border-grey-bottom pb10"> <b><h4 style="text-align:center;" class="mb5 mt5 fontbold lineheight10"> <a href="<?php echo esc_url($store_url . '/section' . '/' . $cat_id);?>"> <?php echo strtoupper($cat_name) . " - Ver más \u{27a1}"; ?> </a></h4></b> </div> <?php } ?>
And the result:
Main vendor’s product page: https://ibb.co/SywLCYH
Other vendor’s product pages (filtered by categories, search, etc): https://ibb.co/BnQfDDn (everything stays the same)
As I said before, I’m learning, so this might not be the best solution, but is very functional (:
- This reply was modified 1 year, 9 months ago by maurosp91.
I tried what you mencioned but the result looks really bad.
Any other idea?
Maybe I can make the store-content element clickable..?
Thanks!
I got with the solution:
$query = new WC_Order_Query( array( 'limit' => 300, 'post_type' => 'shop_order', 'meta_key' => '_dokan_vendor_id', 'meta_value' => $seller_id, 'post_status' => array_keys( wc_get_order_statuses() ), 'status' => array('wc-processing', 'wc-on-hold', 'wc-pending'), 'return' => 'ids', ) ); $user_orders = $query->get_orders();
I get all the order ids from a seller, and with certain order status.
Hope it helps someone else!
Oh, I see. Thanks for your help!
I could figure it our myself.
In case somebody needs it the files are:
dokan-lite\includes\Order\Hooks.php (line 169)
dokan-lite\includes\ReverseWithdrawal\Hooks.php (line 192)If you want to change the label shown on dokan reverse withdrawal admin setting:
– if your language is english then modify:
dokan-lite\includes\ReverseWithdrawal\SettingsHelper.php (line 162)– if your language is different from english use Loco Translate to change this label: “Cash on delivery”
Just add the name of the other payment methods ??
It’s not multiple shippings. It’s part of dokan lite.
I’ll explain what I am doing with more details:
I will provide customers 2 payment options: cash on delivery and QR scanning payment on delivery as well (I manage the delivery service)
I’m just using cash on pick up method to emulate a second type of cash on delivery (because I need dokan to know that QR money goes straight to vendors wallets).Therefore, I need to find a way to unset QR code payment method (emulated by COP) if a vendor just want cash.
I only need help to get the vendor Id at the checkout page using the hook
woocommerce_available_payment_gatewaysThanks a lot!
- This reply was modified 2 years ago by maurosp91.