Phone Orders For WooCommerce

Wholesale Market, By CedCommerce

Wholesale Market by CedCommerce applies wholesale pricing to WooCommerce products based on customer roles — modifying get_price() directly so that registered wholesale customers always receive their tier price wherever WooCommerce reads the product price. When a sales agent adds a product to a Phone Orders cart, the agent session runs as the currently logged-in admin user rather than the selected customer. This means Wholesale Market’s role-based price hook fires for the admin’s role rather than the customer’s, so the cart shows the admin’s price — usually the retail price — instead of the customer’s wholesale price.

This article provides three compact filter hooks that fix the price display and lock it to read-only so agents can’t accidentally override a wholesale price that Wholesale Market already calculated correctly.


Code Sample

Add the following snippet to your child theme’s functions.php or the Code Snippets plugin:

Code Explained (for Developers)

Filter 1 — wpo_prepare_item

ElementDescription
wpo_prepare_itemA Phone Orders filter that fires during cart item preparation, just before the item’s price data gets used for display and order creation.
$product->get_price()Calls WooCommerce’s standard price getter on the product object. Because Wholesale Market hooks into woocommerce_get_price and modifies the return value based on the current user’s role, this call returns the wholesale price for wholesale customers when the product is evaluated in the correct user context. Assigning it to $item['item_cost'] ensures Phone Orders uses this value for the cart line item.

Filter 2 — wpo_update_cart_loaded_product

ElementDescription
wpo_update_cart_loaded_productA Phone Orders filter that fires when an existing cart item reloads — for example when the agent refreshes the cart, changes the quantity, or reopens a draft order. Without this filter the price can revert to the retail value on reload.
$item['data']->get_price()Reads the current price from the WC_Product object stored in the cart item’s data key. Again, Wholesale Market’s filter modifies this value to return the wholesale price for eligible customers.
$loaded_product['readonly_price']Sets the read-only display value shown in the cart UI alongside the price field. Keeping this in sync with item_cost ensures the agent sees the same value in both the editable and display price fields.

Filter 3 — wpo_cart_item_is_price_readonly

ElementDescription
wpo_cart_item_is_price_readonlyA Phone Orders filter that controls whether the price field for a cart item is editable or locked.
__return_trueA WordPress built-in callback that always returns true. Passing it here locks the price field as read-only for every cart item globally. This prevents agents from accidentally overwriting a Wholesale Market price with a manual entry — since Wholesale Market calculates the correct price programmatically, the agent has no reason to edit it manually.

Key concept: Wholesale Market modifies get_price() at runtime based on the currently logged-in user’s role. The Phone Orders backend runs as the admin user, so without this snippet the wholesale modification never fires for the selected customer’s role. These three filters ensure the price Phone Orders uses and displays always comes from a fresh get_price() call — which Wholesale Market intercepts and adjusts — rather than from any cached or session-specific value that Phone Orders might otherwise carry.


How to Apply This Code

  1. Open Appearance → Theme File Editor in your WordPress admin, or open the Code Snippets plugin.
  2. Paste the full snippet into your child theme’s functions.php or create a new dedicated snippet.
  3. Save the file or snippet.
  4. Open Phone Orders and create a test order for a customer with a wholesale role assigned in Wholesale Market.
  5. Add a product that carries a wholesale price for that role and confirm the Phone Orders cart shows the wholesale price rather than the retail price.
  6. Attempt to edit the price field manually and verify it is locked as read-only.

⚠️ Always use a child theme or Code Snippets rather than editing the parent theme’s functions.php directly — parent theme files get overwritten on theme updates.


When Should You Use This Fix?

This snippet applies when your store uses Wholesale Market by CedCommerce for role-based pricing and your sales agents create backend orders through Phone Orders PRO. Without it, agents see retail prices for wholesale customers in the Phone Orders cart, and the resulting orders carry the wrong line item prices. The read-only lock also prevents accidental manual price edits on items whose wholesale price Wholesale Market calculates automatically — keeping order data clean and consistent.

Have questions? Please submit a support request. We're always happy to help!

Phone Orders
for WooCommerce
PRO

From $120
Buy
✓ 30-day money-back guarantee