We are currently implementing the Review functions, which work quite well; however, we want to limit the review only if both parties have an order.
We get an error once we try to submit a review and we are not a buyer, but how can we check if this is true, so we can hide the button in this case or display a different message.
here is our current implementation:
<div class="d-flex flex-sm-row flex-column align-items-sm-center align-items-stretch justify-content-between">
<?php
$args = array(
'fields' => array(
'listing' => array(
'display_type' => 'hidden',
'value' => $listing->get_id(),
),
'text' => array(
'attributes' => array(
'rows' => 5,
),
),
),
'button' => array(
'label' => esc_html__('Leistung bewerten', 'finder'),
'attributes' => array(
'class' => array('btn btn-primary d-block w-100 mb-4 mt-4'),
),
),
);
$listing_review = new Review_Submit($args);
$modal_id_reference = 'user_login_modal';
if (is_user_logged_in()) {
$modal_id_reference = 'review_submit';
}
$modal_content_class = ('car-finder' === $post_style) ? ' bg-dark border-light' : '';
$modal_title_class = ('car-finder' === $post_style) ? ' text-light' : '';
?>
<div class="modal fade listing-single-review-form<?php echo esc_attr('car-finder' === $post_style ? ' finder-form-dark' : ''); ?>" id="review_submit" tabindex="-1" aria-modal="true" role="dialog">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content<?php echo esc_attr($modal_content_class); ?>">
<div class="modal-header d-block position-relative border-0 pb-0 px-sm-5 px-4">
<h3 class="modal-title mt-4 text-center<?php echo esc_attr($modal_title_class); ?>"><?php esc_html_e('Diese Leistung bewerten', 'finder'); ?></h3>
<button class="btn-close position-absolute top-0 end-0 mt-3 me-3<?php echo esc_attr('car-finder' === $post_style ? ' btn-close-white' : ''); ?>" type="button" data-bs-dismiss="modal" aria-label="<?php esc_attr_e('Close', 'finder'); ?>"></button>
</div>
<div class="modal-body px-sm-5 px-4">
<?php echo apply_filters('finder_listing_review_form_output', $listing_review->render()); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</div>
</div>
</div>
<?php
$button_class = ('city-guide' === $post_style) ? ' btn btn-outline-primary rounded-pill' : ' btn btn-outline-primary';
$button_class = ('car-finder' === $post_style) ? ' btn btn-primary' : $button_class;
$author_class = ('car-finder' === $post_style) ? ' text-light' : '';
$review_border_class = ('car-finder' === $post_style) ? ' border-light' : '';
$review_date_class = ('car-finder' === $post_style) ? ' text-light opacity-50' : ' text-muted';
?>
<a class="mb-sm-0 mb-3<?php echo esc_attr($button_class); ?>" href="#<?php echo esc_attr($modal_id_reference); ?>" data-bs-toggle="modal" style="z-index: 1">
<i class="fi-edit me-1"></i>
<?php esc_html_e('Diese Leistung bewerten', 'finder'); ?>
</a>
</div>