Can't get 'set_price_extras' to work

I am trying to use the below code that I found here: Add extra price to listing attributes - #14 by yevhen

add_action(
‘hivepress/v1/models/listing/create’,
function($listing_id, $listing) {
$listing->set_price_extras([[‘name’ => ‘Test’, ‘price’ => 100]])->save_price_extras();
},
1000,
2
);

But when add it to my function.php file nothing happens, and both on admin and frontend it doesn’t auto create the extra price when choosing New Listing. Seeing that original solution is from 2 yrs ago thought to see if maybe it has changed since or what might be doing wrong.
I am using the MarketPlace plugin and have the setting on to enable Pricing Extras in the WP Dashboard > HivePress > Settings > Listings section, and I can make them manually just not have them auto created on new listing.

1 Like

Hi,

Please try adding a listing as a new user and test again. Also, check if you have this feature turned off: How to restrict selling to specific listing categories - HivePress Help Center, as there may be no price extras fields at the time of listing creation.

Additionally, please copy this snippet similarly to this topic Add extra price to listing attributes - #14 by yevhen and add it using this doc: How to add custom code snippets - HivePress Help Center.

​I hope this is helpful to you.

I have already done all those steps.

added the code snippet into the theme’s functions.php:

then these are the settings in use:


(Also tried with all categories removed, so applies to All)

Also tried the suggestion the one person said of getting it working by doing a create-delete-create listing. Made no difference.
Tried it on clean staging site, and also no luck.

When make New Listing just seeing below:

Details: WordPress 6.5.5, HivePress 1.7.4, HivePress Marketplace 1.3.11, ListingHive 1.2.9(theme)

1 Like

Hi,

We checked this issue from our side, and it seems okay. When you create a new listing, everything is displayed correctly, as shown in the screenshot: Awesome Screenshot

Please make sure you don’t have any restrictions on selling categories: How to restrict selling to specific listing categories - HivePress Help Center

I believe this will be useful to you.