Hello,
I am trying to address a problem/missing feature that has been already raised here by @kikomigo, that is , to allow customer to contact vendor from the request page (in the offer section), by adding the blue icon here below :
For this, I’ve overriden the \hivepress-requests\templates\offer\view\offer-bidder.php
template (now in /myawesome-custom-plugin/hivepress/offer/view
) and added some custom code :
<div id="message_send_modal_1231" class="hp-modal" data-component="modal" style="display: none;">
<h3 class="hp-modal__title">Envoyer un message</h3>
<?php echo ( new HivePress\Blocks\Message_Send_Form( ['values' => ['recipient' => $vendor->get_id()] ] ) )->render();?>
</div>
<!-- blue icon below : -->
<a href="#message_send_modal_1231" title="" class="hp-vendor__action hp-vendor__action--message" aria-describedby="ui-id-1"><i class="hp-icon fas fa-comment"></i></a>
<?php
echo '[debug] vendor id : ' . $vendor->get_id();
For the moment ‘1231’ is hardcoded in various html attributes, but it would be easy to replace id by $vendor->get_id();
which returns the current vendor_id; (as seen in the screenshot above).
So the pop-up opens, but I have a json error message when I submit (so the message is never written in database) :
POST https://myawesomewebsite.fr/wp-json/hivepress/v1/messages/ 400 (Bad Request)
Here the HTML generated for the given form :
<form data-model="message" data-message="Votre message a été envoyé." action="#" data-action="https://lancelo.fr/wp-json/hivepress/v1/messages/" method="POST" data-component="form" class="hp-form hp-form--message-send" data-gtm-form-interact-id="0">
<div class="hp-form__messages" data-component="messages" style="display: none;"></div>
<div class="hp-form__fields">
<input type="hidden" name="recipient" value="1231" data-component="number" class="hp-field hp-field--hidden"><input type="hidden" name="listing" value="" data-component="number" class="hp-field hp-field--hidden">
<div class="hp-form__field hp-form__field--textarea"><label class="hp-field__label hp-form__label"><span>Message</span></label><textarea name="text" maxlength="2048" required="required" class="hp-field hp-field--textarea" data-gtm-form-interact-field-id="0"></textarea></div>
</div>
<div class="hp-form__footer"><button type="submit" class="hp-form__button button-primary alt button hp-field hp-field--submit" style="box-shadow: rgba(255, 193, 7, 0.35) 0px 5px 21px;" data-state=""><span>Envoyer un message</span></button></div>
</form>
At times, I have the following error message (but not so often) :
which translates as ‘recipient field is required’, but the value seems to be passed along :
<input type="hidden" name="recipient" value="1231" data-component="number" class="hp-field hp-field--hidden">
How to address the problem ?
Thank you for your consideration.