我有以下代码字符串...
条件:仅当产品类别为“石头”时才
在价格
如果价格是空的,而不是说0美元,它说“要价”
目标:当产品没有价格或为零时,我希望数量选择器在产品页面上保持可见。
// Add's feet squared to pricing only if prododuct category is 'stone'
add_filter( 'woocommerce_get_price_html', 'custom_price_message' );
function custom_price_message($price) {
if ( !has_term( 'stone', 'product_cat' ) ) {
return $price;
} elseif (!empty($price)){
$vat = ' per ft<sup>2</sup>';
return $price . $vat;
}else{
return 'Call for Price';
}
答案 0 :(得分:0)
class RequestViewSet(viewsets.ModelViewSet):
queryset = ml_request.objects.all()
serializer_class = RequestSerializer
permission_classes = (IsAuthenticatedOrReadOnly,
IsOwnerOrReadOnly,)
@detail_route(renderer_classes=[renderers.StaticHTMLRenderer])
def highlight(self, request, *args, **kwargs):
snippet = self.get_object()
return Response(snippet.highlighted)
def perform_create(self, serializer):
serializer.save(owner=self.request.user)