• Resolved philipatnedi

    (@philipatnedi)


    Hello! I’m trying to build out some custom functionality in my functions file so that I can access the wholesale pricing for a line item product in a WooCommerce Order. I tried checking the knowledge base and couldn’t find anything so I thought I’d try here.

    I’m working with Autoship Cloud, which allows for recurring monthly orders, but it only cares about the WooCommerce price and completely ignores the wholesale price. Is there a list of functions available using the Wholesale Prices plugin for me to use so that I can both check for and get the wholesale price?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Philip, you may find your answer in wp-content/plugins/woocommerce-wholesale-prices/includes/class-wwp-wholesale-prices.php ??

    This also interests me becuase if I need to manually add items to order (in ‘edit order’, after checkout) the wholesale pricing would not be brought in and requires a fiddle, or do a new order and edit out the shipping and explain to customer why two invoices.

    Ideally a snippet could be provided to parse orders and ensure correct pricing for the customer (without changes to completed orders).

    Thread Starter philipatnedi

    (@philipatnedi)

    I found the following function in class-wwp-wholesale-prices.php:

    public static function get_product_raw_wholesale_price($product_id, $user_wholesale_role)

    Which should work in my case as I’d have the product id, (variation), and can simply use the one wholesale user role we set up. I can also test the customer assigned to the order to see if they have the wholesale user role. What I’m not sure of is if I can use this within functions.php without any additional setup. I’ll have to test it out and see if it works for me.

    Plugin Support Fauzan Azizie

    (@fauzanade)

    Hi @philipatnedi,

    You can also try the following snippet:

    function wpp_get_wholesale_price() {
    global $wc_wholesale_prices;
    global $product;
    $productID = $product->get_id();
    
    $wholesale_roles = $wc_wholesale_prices->wwp_wholesale_roles->getAllRegisteredWholesaleRoles();
    // loop through wholesale roles
    foreach( $wholesale_roles as $wholesale_role => $data ) {
    	// get wholesale price of product per wholesale role
    	$wholesale_price_data = WWP_Wholesale_Prices::get_product_wholesale_price_on_shop_v3($productID, array( $wholesale_role ) );
    	// category level wil output 'product_category_level', per product is 'per_product_level'. general is 'wholesale_role_level'
    	$wholesale_price_source = $wholesale_price_data[ 'source' ];
    	// wholesale price
    	$wholesale_price = $wholesale_price_data[ 'wholesale_price' ];
    	
    	}
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Obtaining wholesale pricing in functions file’ is closed to new replies.