在不使用插件的情况下为WooCommerce订单号添加后缀和前缀

时间:2016-08-05 07:16:02

标签: php wordpress woocommerce orders

我想在不使用插件的情况下为Woo Commerce订单号添加后缀和前缀。

我试图使用这个无效的钩子:

add_filter( 'woocommerce_order_number','my_woocommerce_order_number', 1, 2);

function my_woocommerce_order_number( $oldnumber, $order ) {    
    return 'VC'.$order->id;
}

我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:3)

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">
<ol>
<li ng-repeat="element in elements">
    <input type="text" ng-model="element.value"/>
    </li>
</ol>
<br/>
<b>Click here to add Textbox:</b><br/><input type="button" value="New Item" ng-click="newItem()"/>
<br/>
<br/>

<b>Click here to see ng-model value:</b><br/>
<input type="button" value="submit" ng-click="show(elements)">

</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
 var counter=0;
    $scope.elements = [ {id:counter, value : ''} ];

    $scope.newItem = function(){
        counter++;
        $scope.elements.push(  { id:counter,value:''} );
        
    }
    
    $scope.show=function(elements)
    {
        alert(JSON.stringify(elements));
        
    }
  
});
</script>
</body>
</html>

参考:https://docs.woocommerce.com/wc-apidocs/source-class-WC_Order.html#379