• Resolved ibar

    (@ibar)


    Hello,
    I want to modify a plugin that outputs a pdf catalog of the shop.
    Everything works great exept that I want to show the Wholesale price and not the normal.

    This is the code (I think) that generates the normal price:

    $price = $this->product->get_price_html();
    $price = htmlspecialchars_decode($price);
    $price = str_replace(array('₽'), 'RUB', $price);

    How can I replace the normal price with the Wholesale price?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Support Fauzan Azizie

    (@fauzanade)

    Hi @ibar,

    You can use the following snippet to fetch the wholesale price from a product.

    global $wc_wholesale_prices;
    $currentUserRole = $wc_wholesale_prices->wwp_wholesale_roles->getUserWholesaleRole();
    $productID = $product->get_id(); // get product id
    $wholesaleProduct = WWP_Wholesale_Prices::get_product_wholesale_price_on_shop_v3( $productID, $currentUserRole );
    $wholesalePrice = $wholesaleProduct[‘wholesale_price’]; //get wholesale price

    Cheers,

    Thread Starter ibar

    (@ibar)

    Hello,

    Thanks for the replay.
    Unfortunately it doesn’t return anything.
    Maybe it has to do with the $currentUserRole because I am running the script as administrator not as Wholesale user.

    Thread Starter ibar

    (@ibar)

    Any idea why it isn’t working?

    Thanks in advance

    Plugin Support Fauzan Azizie

    (@fauzanade)

    Hi @ibar,

    I want to modify a plugin that outputs a pdf catalog of the shop.

    May I know which plugin that you are using so I could test it on my end?

    Thread Starter ibar

    (@ibar)

    Hello,

    Its this one Woocommerce pdf catalog.
    I can send it to you if you want.
    The file that has to be changed is public/class-woocommerce-pdf-catalog-product-templates.php

    Plugin Support Fauzan Azizie

    (@fauzanade)

    Hi @ibar,

    Could you please send it to us via [email protected]?

    Cheers,

    Thread Starter ibar

    (@ibar)

    Hello,
    I send it trough wetransfer.

    Thread Starter ibar

    (@ibar)

    Hello,
    have you received it?

    Plugin Support Fauzan Azizie

    (@fauzanade)

    Hi @ibar,

    Yes, I’ve received it and it seems it’s working well for me.

    When I export the PDF Catalog, I get the wholesale price correctly. Please keep in mind that you need to log in as a wholesale customer to get the wholesale price. Here’s a screencast: https://www.loom.com/share/04dd5d376602484797fdf519aeaf0848

    Also, here’s the PDF I exported: https://we.tl/t-bt7Wgbt9vv

    Thread Starter ibar

    (@ibar)

    Isn’t it possible to use it when I am logged-in as administrator?

    Plugin Support Fauzan Azizie

    (@fauzanade)

    Hi @ibar,

    Thanks for keeping in touch!

    I’m afraid it’s not possible. From the WooCommerce PDF Catalog itself, there’s no function to export the catalog from the backend, so you’ll need to export it on the shop page. So for a regular price, you can use the admin and regular customer account.

    But for a wholesale price, you’ll need to be logged in as a wholesale customer.

    Thread Starter ibar

    (@ibar)

    Ok, I can live with that.
    What code did you used? Exactly the files I have send you?
    Because I still can’t see the prices, even when logged-in as a wholesale customer.

    Plugin Support Fauzan Azizie

    (@fauzanade)

    Hi @ibar,

    Yes, I didn’t change anything.

    In fact, when I removed the snippet I gave you and use the original price snippet, it output the price with a better styling: https://we.tl/t-51qXP93Ubh

    Thread Starter ibar

    (@ibar)

    I found out what is going wrong.
    Your snippet code doesn’t return any value on variable products (that I am using mostly). Without it, it works.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘How to insert Wholesale price programmatically’ is closed to new replies.